-
get updates from branch (-r puts your commits on top of the pull, don't do this if you're not the only one working on the branch)
git pull -r -
push local commit
git push origin <branch> -
create new branch (and switch to it)
git checkout -b <new branch name> -
go to other branch
git checkout <branch to switch to> -
push from branch
git push origin <branch> -
squash (last 2 into 1)
git rebase -i -p HEAD~2 git push -f origin <branch> -
see commit history
git log -
see difference current branch with master
git diff master <current branch> -
see current changes from last commit
git diff HEAD^ -
reset to current state on server (can also be used to reset to repo that's been forced push)
git fetch --all git reset --hard origin/<branch> -
get changes from master
git rebase master git merge master // merge as commit -
see detailed command history
git reflog -
set new origin
git remote set-url origin <url> // verify git remote -v -
reset if file is not gitignored
git rm -r --cached . git add . -
reset fork to upstream
git remote add upstream </https-or-ssh/url/to/original/repo> git fetch upstream git checkout master git reset --hard upstream/master git push -f -
add fork remote
git remote add fork <url> -
set push to fork remote
git push --set-upstream fork <branch> -
diff uncommitted changes with current commit
git diff -
diff current commit with previous commit
git diff HEAD^ HEAD -
remove branches that are not in upstream anymore
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
Last active
April 25, 2019 09:19
-
-
Save chrisvdg/c0767d8cf5dee3cf5024458d99bea9a7 to your computer and use it in GitHub Desktop.
Git notes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment