Sunday, December 29, 2013

Commonly used git commands

  • git checkout oldbranch # Checkout an existing branch
  • git checkout -b newbranchname  # Create a new branch 
  • git checkout -b newbranch remote/newbranch # to avoid confusions

  • git status  # See your changes

  • git branch --all | grep pattern      # All branches in all repos you have added
  • git branch                                     # to list local branches

  • git push --dry-run     # See what you are going to push
  • git push                     # Actually push

  • git config branch.branchname.remote    # to see the value
  • git config branch.branchname.remote  privatebranch   # to set the value

  • git config branch.branchname.merge
  • git config branch.branchname.merge branchname # the remote merge branch 

 # Show all commit logs for all commits on branch1 that are not on branch2
  • git log branch1 ^branch2 --no-merges 
  •   git push origin :branchname    # Delete a remote branch
  •  git remote add newrem git+ssh://path.to.git/remote
# Run this as soon as you add a remote repository. To download all branches.
  • git fetch
  • git fetch remote