Skip to content

Instantly share code, notes, and snippets.

@chauhan-utk
chauhan-utk / Basics.md
Last active September 11, 2019 10:03
Git and GitHub basic commands

Basic git commands:

  • git fetch : get remote commits to local repo
  • git pull <repo> <branch-name> e.g. git pull origin master : get the commits from remote branch to current branch
  • git branch -a : list all branches including remote branches
    • git checkout <branch-name> : switch to the branch
  • git branch -m <new-name> : rename current local branch. Check this for more information.
  • git checkout -b <new-branch> : create a new branch based on the current branch
    • git checkout -b <new-branch> <existing-branch> : create a new branch given an existing branch
  • git status : list of files tracked and not tracked
  • git add . or git add : add files to staging area
@CristinaSolana
CristinaSolana / gist:1885435
Created February 22, 2012 14:56
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream