Git

1 min read

remove big file from git

git filter-branch --tree-filter 'rm -rf src/image_similarity' HEAD

git reset HEAD~

rebase

  • no rebase or amend in public repositories

git stash

git checkout branchname

git rebase -i

git rebase continue

git rebase --drop

rebase on a historical commit

git stash

-> checkout to the commit

-> make changes

-> amend commit

-> create new branch there

-> checkout to master again

git rebase rebaser

-> solve conflicts

git rebase continue

stash

git stash apply

git diff

git stash drop

remote

git remote rm remotename

git remote add remoteurl

git remote set-url remotename newurl

git remote show origin

branch

guide

$ git branch

$ git checkout [name_of_your_new_branch]

$ git checkout -b [name_of_your_new_branch]

$ git push [name_of_your_new_remote] [name_of_your_branch]

reset

git undo all uncommitted or unsaved changes like a fresh git clone

git reset

git checkout .

git clean -fdx

remember credentials

# Set the cache to timeout after 1 hour (setting is in seconds)

git config --global credential.helper 'cache --timeout=3600'

oh shit git

git tips

January 2, 2020