Skip to content

Instantly share code, notes, and snippets.

@oheil
Last active September 8, 2023 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oheil/b38facb1f8c6b755dd3fd66718fbe3a8 to your computer and use it in GitHub Desktop.
Save oheil/b38facb1f8c6b755dd3fd66718fbe3a8 to your computer and use it in GitHub Desktop.
git cheat sheet

https://github.github.com/training-kit/downloads/github-git-cheat-sheet.pdf

Initially clone a repository

git clone https://github.com/oheil/NormalizeQuantiles.jl

cd NormalizeQuantiles

git checkout branch-name

Update local from remote repository

git pull origin master

git fetch

git pull

Update fork from upstream master

https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork

git fetch upstream

git checkout master

git merge upstream/master

git push

Remove tags, example for tag="v0.1.4"

first local:

git tag -d v0.1.4

push to remote

git push origin :v0.1.4

resolve conflicts after merge

Source: https://easyengine.io/tutorials/git/git-resolve-merge-conflicts/

show git conflicts:

git status

show only files with conflicts:

grep -lr '<<<<<<<' .

show all conflicts, navigate with :n to next conflict

grep -lr '<<<<<<<' . | xargs less

edit complex conflicts using editor and add local file, e.g.
vim file
git add file
bulk accept local/our version

grep -lr '<<<<<<<' . | xargs git checkout --ours

bulk accept remote/other-branch

grep -lr '<<<<<<<' . | xargs git checkout --theirs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment