Jeremy's Wiki

everything but the kitchen sink

User Tools

Site Tools



Oh-My-Zsh git command alias reference (kudos to thoughtworks)

Things NOT to do

  • NEVER force push to remote branches

Amend author of last commit

git commit --amend --author="John Doe <>"

Reset file

git checkout -- path/to/file


git pull --rebase

# or

git pull --no-ff



–soft is discarding last commit,

–mix is discarding last commit and add,

–hard is discarding last commit, add and any changes you made on the codes which is the same with git checkout HEAD


git branch -a

Delete local

git branch -d test

Delete remote

git push origin --delete test

Cleanup branches on local which have been deleted on remote

git fetch --prune

How to: Fixup bad commit

git reset --soft HEAD^

# or

git reset --soft HEAD~1

Then reset the unwanted files to leave them out from the commit:

git reset HEAD path/to/unwanted_file

# or

git rm --cached path/to/unwanted_file

Now commit again, you can even re-use the same commit message:

git commit -c ORIG_HEAD

How to: Remove modified files from PR

git checkout origin/master -- src/main/java/
git commit -m "Removed a modified file from pull request"
git push origin <pull-request-branch>

How to: Rebase active branch onto another branch

First, commit your current changes

git commit
git checkout -b backup

Secondly, switch to the target branch

git checkout master

Thirdly, rebase the source branch onto the target branch

git rebase <parent commit hash BEFORE first feature commit> --onto <feature branch name> --committer-date-is-author-date

fatal: cannot rebase with locally recorded submodule modifications

"fatal: cannot rebase with locally recorded submodule modifications"

Run commands separately:

git fetch
git rebase
git submodule update


git rebase --no-recurse-submodules


Commit your submodule changes before rebasing

git_commands.txt · Last modified: 2023/07/06 05:00 by superuser

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki