git config --global user.name "Stevie Wonder"
git config --global user.email "[email protected]"
git init
git clone <url>
git pull origin master
git remote set-url origin <url>
git remote add <remote-name> <url>
git remote -v
git remote rm <destination>
git checkout -b <branch-name>
git branch -d <branch-name>
git branch
git checkout <branch-name>
git push -u origin <branch-name>
git push origin :<branch-name>
git config --global alias.st status
git config --global alias.ci commit -m
git config --global alias.cob checkout -b
git diff
git stash
Remove a single stashed state from the stash list and apply on top of the current working tree state
git stash pop
git stash list
git stash clear
git add .
git reset --hard
git add <file1> <file2>...
git rm <file1> <file2>...
git commit -m "<message>"
git commit --amend -m "<message>"
git reset --soft HEAD^
git reset HEAD .
git rebase master
git push origin <branch-name>
git rebase -i master
git diff <branch-name1> <branch-name2>
git revert <HASH>
git push origin master
git log
git log -p
git log --pretty=oneline
git branch |
grep -v "master" |
xargs git branch -D
git branch |
grep -v "master\|develop" |
xargs git branch -D
git branch --merged master
git branch --merged
git branch --no-merged
git branch -r --merged |
grep origin |
grep -v '>' |
grep -v master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
git remote add upstream <parent-repo-url>
git fetch upstream
git rebase upstream/master
git push -f origin master
git submodule update --init --recursive
git clean -f -d
git init
git add .
git commit -m "commit message"
git remote add origin <remote repository url>
git push -u origin master
git remote set-head origin <branch>
carthage checkout --use-submodules
carthage build --no-skip-current
git config --list | grep alias
git config --global --unset alias.lg
[alias]
mr = !sh -c 'git fetch $1 merge-requests/$2/head:mr-$1-$2 && git checkout mr-$1-$2' -
[alias]
pr = !sh -c 'git fetch $1 pull/$2/head:pr-$1-$2 && git checkout pr-$1-$2' -
git mr upstream <MR Number>
git pr upstream <PR Number>
git pull upstream master
git push origin master
git count-objects -vH | grep "size-pack"
https://superuser.com/questions/229290/how-to-amend-the-last-commit-to-un-add-a-file
- single file
git rm -r --cached filename
- all files in
git rm -r --cached .
git add .
Every time you fetch from a remote, tracking braches are pulled down from the remote. After a while you'll find you have lots of origin/*
branches in your local repro which no longer exist on the remote. To find out which branches they are, run this command:
git remote prune origin --dry-run
To go ahead and delete those branches it's:
git remote prune origin
You can also prune when you fetch from a remote. To do this use the --prune option:
git fetch --prune
git checkout <git SHA>
git switch -c <branch name>
ggpush
gcp <git sha>
ggpush
More tips - https://github.com/jbranchaud/til#git