2020-10-02T23:29:27+02:00
There are a few git commands I use all the time. I want to share them.
Create a new feature or switch between two:
git checkout -b BRANCH
git checkout BRANCH
To get an idea about what to commit:
git status
git diff
git diff --cached
Mark file changes for commit (stage them:)
git add -p FILE
Commit changes, merge with the previous commit:
git commit -m'MESSAGE'
git commit --amend
Show the repository history the way I can understand. I have an alias for this:
git log --oneline --graph --decorate --all
Show particular commit changes:
git show COMMIT
Sometimes needed before/after rebase:
git stash
git stash pop
Take the current branch and put it on top of BRANCH_OR_COMMIT. Do it iteratively, so change what needs to be changed:
git rebase -i BRANCH_OR_COMMIT
Merge the BRANCH to the current branch. However, do not meld it:
git merge --no-ff BRANCH
Do not forget that all the git magic is damned if you don’t know how to write a git commit message.