Skip to content

Instantly share code, notes, and snippets.

@derofim
Created June 20, 2017 04:04
Show Gist options
  • Save derofim/7e1ff10402510b9bd800b7a725f8eeb8 to your computer and use it in GitHub Desktop.
Save derofim/7e1ff10402510b9bd800b7a725f8eeb8 to your computer and use it in GitHub Desktop.
git

Clone repository with specific branch and tag

git clone --recursive -b {branch} {remote_repo} .
git checkout {tag_name} -b {branch_name}

Contributing to a Project

Tutorial - Contributing to a Project

Git setup

Tutorial - Git setup

Push an existing repository from the command line

git remote add origin {URL}
git push -u origin {BRANCH}

Create a new repository on the command line

git init
git add .
git commit -m "{COMMENT}"
git remote add origin {URL}
git push -u origin {BRANCH}

Save changes

git add .
git commit -m "{COMMENT}"
git push -u origin {BRANCH}

Tag version (commit local changes first before tagging)

git add .
git commit -m "{COMMENT}"
git push -u origin {BRANCH}
git tag -a {TAG_NAME} -m "{COMMENT}"
git push origin {TAG_NAME}

Delete tag

git push --delete origin {TAG_NAME}

Sync local repo with remote one (Undo changes)

git fetch origin --prune
git reset --hard
git pull

Switch to commit by it`s number (commit local changes first before checkout)

git checkout {COMMIT}

Create branch

git checkout -b {BRANCH}

Switch branch

git pull
git checkout {BRANCH}

Fix merge conflicts in GUI (You can install one of the following tools: meld, opendiff, kdiff3, tkdiff, xxdiff, tortoisemerge, gvimdiff, diffuse, ecmerge, p4merge, araxis, vimdiff, emerge)

git mergetool --tool=emerge

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