Wednesday, 10 May 2017

GIT Clone, Pull, Merge and Checkout

Get your copy of the repository:

  git clone $URL

Or initialize it locally

  git init

Browse remote repos and branches

  git remote -v update #
  git branch -r -vv #show remote branches
  git branch -vv #show local branches

Choose your remote and local branches to work 

  git branch -r  #list remote branches
  git branch $BRANCH #create a local branch
  git checkout $BRANCH #change into the branch
  git checkout -b $BRANCH origin/develop #create a new branch from origin/develop
  git checkout <sha> #go to a commit instead of a branch

Update your working copy from remote:

  git fetch --all  #update all remote info
  git merge     #apply commits done on remote #DONT REBASE!

Or use pull:

  git pull [--all] #fetch + merge , DONT --rebase!!

NEVER USE "git rebase $BRANCH" or "git rebase master"IT WILL DELETE COMMITS!

No comments:

Post a Comment