Oh-My-Zsh git command alias reference (kudos to thoughtworks)
git commit --amend --author="John Doe <john@doe.org>"
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
List
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
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
git checkout origin/master -- src/main/java/HelloWorld.java git commit -m "Removed a modified file from pull request" git push origin <pull-request-branch>
https://stackoverflow.com/questions/39459467/remove-a-modified-file-from-pull-request
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"
Run commands separately:
git fetch git rebase git submodule update
OR
git rebase --no-recurse-submodules
OR
Commit your submodule changes before rebasing