Skip to content

Instantly share code, notes, and snippets.

@andretw
Last active September 17, 2015 04:00
Show Gist options
  • Save andretw/684ff1da16510f2d56cd to your computer and use it in GitHub Desktop.
Save andretw/684ff1da16510f2d56cd to your computer and use it in GitHub Desktop.
Useful Git tips.

(Seems like) To move n commits (not pushed to remote branch yet) from master branch to a new branch (mynewbranch)

git branch mynewbranch        # copy current commits to the new branch
git reset --hard HEAD~1       # reset 1 commit, replace 1 to n or any other natural number you want. 

To change last commit message.

git commit --amend -m 'new message'

Force change the commit on the remote branch

git push <remote> <branch> -f

Change all user.email in the directory

for d in ./*/ ; do (cd "$d" && git config --local user.email [email protected]); done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment