Handy GIT commands

git
Standard

Pull latest changes while doing a rebase.

git pull --rebase origin master

Merge from a branch back to master

git merge --no-ff --no-commit <branch-name>

–no-ff : preserve the branch structure and not just place branch commits on top of master branch.

–no-commit: Don’t auto-commit. This allows you to discard some changes first e.g. a pom.xml version number that is relevant to the merge branch, but not to the master branch.

Throw away last commit [should stash first]

git reset --hard HEAD~

Remove all changes including untracked files [should stash first]

WARNING: this will remove all untracked files as well e.g. “.bat/.sh” files that you may use to do special builds or deployments.

git clean -df
git checkout -- .

 

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s