Skip to content

Instantly share code, notes, and snippets.

@Dangeranger
Last active August 29, 2015 14:21
Show Gist options
  • Save Dangeranger/9f213194c866bcc2eaf4 to your computer and use it in GitHub Desktop.
Save Dangeranger/9f213194c866bcc2eaf4 to your computer and use it in GitHub Desktop.
Useful Git Commands

###Checkout a remote branch and set it to track the remote

This will keep your local branch in sync with the remote on push/pull/fetch

[email protected]:~$ git branch -vv

  joshes_branch   6a1e534 [origin/joshes_branch] added script tags to index.html
  daves_branch    4577b3b [origin/daves_branch] updated the css to be more responsive

[email protected]:~$ git checkout --track origin/daves_branch

  branch daves_branch set up to track remote branch daves_branch from origin.
  Switched to a new branch 'daves_branch'

###Push a new local branch to the remote origin and setup tracking

[email protected]:~$ git checkout -b feature_branch

[email protected]:~$ vim some_file_to_change.rb

[email protected]:~$ git add . # or add files one-by-one

[email protected]:~$ git commit -m "some awesome message here"

[email protected]:~$ git push -u origin feature_branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment