Git useful commands and stuff
|
Which commit does this branch come from?
git merge-base new_branch old_branch
|
|
Which merged branches were not deleted?
for branch in `git branch -r --merged origin/master | grep -v HEAD`;do echo -e `git show --format="%ai %ar by %an" $branch | head -n 1` \\t $branch; done | sort -r
|
|
How to amend a (non-pushed) commit?
git commit --amend --no-edit
|
|
How to clear local tags
git fetch --prune origin "+refs/tags/*:refs/tags/*"
|
|
How to display information about origin?
git remote show origin
|
|
How to setup the upstream of branch?
git checkout --track origin/branchname
|
|
How to reset local branch to remote's HEAD?
git reset --hard origin
|
|
How to check out more than one branch at a time?
git worktree
|
[core]
excludesfile = ~/.gitignore
autocrlf = false
eol = lf
[include]
path = ~/.gitconfig-local
[fetch]
prune = true
[push]
autoSetupRemote = true
default = upstream
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = yellow
changed = green
untracked = cyan
remoteBranch = cyan
[alias]
lg = log --graph --oneline
hist = lg --decorate --all
st = status -sb
co = checkout
br = branch
pushf = push --force-with-lease
ver = describe --tags
fuckup = commit --fixup HEAD
praise = blame
|
How to include stage in diff?
git diff --staged
|
|
How to diff words instead of lines?
git diff --word-diff
|
|
What has changed in a file?
git diff HEAD~1..HEAD file.txt
|
|
How to diff a file with main?
git diff HEAD..main file.txt
|
|
How to diff a stash with the commit it's based on?
git diff stash@{0}^!
|
|
How to see the most recent stash?
git stash show -p stash@{0}
|
git fetch
git checkout feature/feature-x
git commit -m "Add feature x"
git push
git checkout develop
git pull
git checkout feature/feature-x
git rebase develop
git add *fixed files list*
git rebase --continue
git checkout develop
git merge --no-ff feature/feature-x
git push
git branch -D feature/feature-x
git push origin :feature/feature-x
git log --oneline |
git log --stat |
git log --name-status |
git log --follow --pretty=format:'%an (%ae)' file.c | sort | uniq |
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.