Skip to content

Instantly share code, notes, and snippets.

@gustavofranke
Last active January 25, 2021 17:15
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 gustavofranke/a91b7bb6cdfa42a8adb8 to your computer and use it in GitHub Desktop.
Save gustavofranke/a91b7bb6cdfa42a8adb8 to your computer and use it in GitHub Desktop.
Git basics.md
  • list local configs: git config --list

  • create a branch: git branch testing, testing is the branch name

  • point to a branch: git checkout testing git checkout master

  • create and point to a branch: git checkout -b testing

  • list of current branches: git branch

  • merge: git checkout master ; git merge testing

  • delete a branch: git branch -d testing

  • to point a local copy to a different url: git remote set-url origin

  • to revert all changes to be just like remote repository head: git fetch origin && git reset --hard origin/master

  • to point local branch to different remote repo: git remote set-url origin <the .git address>

  • to know the remote location the local copies are pointing: git remote -v

  • checkout remote branch: git checkout -b somexxx origin/SomeRefactorings

  • list current remote branches: git branch -r

  • if git branch -r shows already deleted remote branches run git fetch origin --prune and then git branch -r back again

  • git remote add upstream git@github.xxxx.xxx:xxx/original-repo-url.git then git remote -v

origin    git@github.xxxx.xxx:gustavo-franke/original-repo-url.git (fetch)
origin    git@github.xxxx.xxx:gustavo-franke/original-repo-url.git (push)
upstream    git@github.xxxx.xxx:xxx/original-repo-url.git (fetch)
upstream    git@github.xxxx.xxx:xxx/original-repo-url.git (push)

git fetch upstream *

git checkout -b test <name of remote>/test
git checkout -t <name of remote>/test
  • git pull upstream development --rebase
  • git stash show -p stash@{1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment