yingmu52
9/7/2017 - 6:00 PM

Git Commands

Some Useful git commnads

Check commit history around lines

git blame -L<line-number>,+<range> -- <filename>
git log --pretty=short -u -L <line-number>,<line-number>:<filename>

Check other people's merge commits

git merge --squash <branch-name>

Undo a git push

git push -f tony HEAD^:test

Reset a unstage file

git checkout -- filename

Squash Last X commits

git reset --soft HEAD~N && git commit -m "Message Here"
git push origin develop

Abort git pull

git reset --merge

Force syncing upstream

git fetch upstream
git reset --hard upstream/develop

Delete a pushed commit

git reset —-hard f3abe64
git push tony develop -f 

Set alias

git config --global alias.pr 'pull --rebase upstream develop

Add Remote

git remote add <remote-nickname> <remote-url>

Rename Branch

git branch -m <new-name>

Remove all changes in Main.storyboard

  • check out the feature branch in the pull request
  • git checkout -- <file-path>
  • git commit --amend --no-edit