git
Resources
Commits
git commit --amend
- To edit a commit message or add files to the previous commit.
git rebase -i '<commit hash>^'
- Modify commits using:
reword
to edit commit message
edit
to edit commit
- commit corrections with
git commit --amend --no-edit
- and then
git rebase --continue
git commit <remote> <branch> -f
- Force push a commit (if it was already push and then locally modified).
- Links
- List tags with message:
git tag -n
- Create annotated tag and push:
git tag -a -m <tag message> <tag name> [commit hash]
git push --tags
or git push <remote> <tag name>
- Remove tag that is already pushed:
- remove tag on remote with
git push origin :refs/tags/<tag name>
, :
stands for --delete
- replace tag locally with
git tag -af <tag annotation> <commit hash>
, -f
means replace existing tag.
- force push tags with
git push --tags -f
Config
# disable pager mode when doing git branch
git config --global pager.branch false
# set a global gitignore file
git config --global core.excludesfile ~/.config/git/global-ignore
# aliases
git config --global alias.co checkout
Misc
git fetch/pull -p
- Removes any remote-tracking references that no longer exist on the remote.
git show
- Show changes in latest commit.
git log --oneline --graph --all
- Nice view of commit history
git add -p