Git tips

How do I discard changes in my working copy that are not in the index?

git stash save --keep-index --include-untracked

You don't need to include –include-untracked if you don't want to be thorough about it.

or drop the stash

git stash drop

or all unstaged files in current working directory use:

git checkout -- .

For a specific file use:

git checkout -- path/to/file/to/revert

Add alias:

git branch -a| grep xxx

# ~/.gitconfig
[alias]
        squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f"
        last = log -1 HEAD
        bag = "!f() { git branch -a | grep ${1} --color=auto; }; f"

Reference

About Tang

A mobile developer, work in Stockholm, Sweden
This entry was posted in git and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s