- Edit Last Commit Message
- Edit Several Commits Message
- Squash Commits
- Make Pull Requests in GitHub
- Cherry Pick From Another Repository
- Get Churn Count
- Get Commits Log in Pretty Style
- Get Commits Graph
- Tools
git commit --amend
- Mark commits which you want to edit by
git rebase -i HEAD~X
- Edit each commit message by
git commit --amend
- Finish rebase operation by
git rebase --continue
- Push your changes with forcing to the server by
git push origin BRANCH -f
- Make commits which you want to squash by
git rebase -i HEAD~X
- Finish rebase operation by
git rebase --continue
- Push your changes with forcing to the server by
git push origin BRANCH -f
- Fork the target repo
- Checkout your (forked) copy of target repo
git checkout your-repo-url
- Create new feature branch by
git checkout -b your-feature
- Push your feature branch
- Create Pull Request with this feature branch
- Connect another remote repo:
git remote add project-b git://github.com/username/project-b.git
- Fetch changes from it:
git fetch project-b
- Have a look at commits:
git log project-b/master
- Select a commit to cherry pick to your repo
- Do it:
git cherry-pick 42a5623ecb0db5da356bb0be01dacfe17b8014e5
- It could be commited immediately
- It may cause a merge conflicts - you should resolve it and commit with
git commit -a
- Push you changes
git push origin master
- Sometimes it could failed with error
Updates were rejected because a pushed branch tip is behind its remote hint: counterpart.
:- Create cherry-picked changes as a new branch
git branch feature-A
- Reset to origin point, e.g.:
git reset --hard HEAD~1
- Merge and push changes.
- Create cherry-picked changes as a new branch
Churn Count displays how much times a given files has been modified to detect which modules are causing problems most often and should be refactored.
Next command show you the churn counts for an entire Git repo or specific files/directories in it. To get top 10 modified files run:
git log --all -M -C --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort -n | awk 'BEGIN {print "count\tfile"} {print $1 "\t" $2}' | tail -n10
git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all
Next command will format your git log
output to display it as a colored graph with commits and merging.
git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all