Skip to content

Instantly share code, notes, and snippets.

@myfavouritekk
Last active August 29, 2015 14:17
Show Gist options
  • Save myfavouritekk/f525762cff212c2fda6a to your computer and use it in GitHub Desktop.
Save myfavouritekk/f525762cff212c2fda6a to your computer and use it in GitHub Desktop.
Git: Common Routines

#Git: Common Routines

Remote repositories

  • Fetch the branches and their respective commits from the upstream repository.
$ git fetch upstream
  • Check out your fork's local master branch.
$ git checkout master
  • Merge the changes from upstream/master into your local master branch. This brings your fork's master branch into sync with the upstream repository, without losing your local changes.
$ git merge upstream/master

Pulling into a dirty tree

When your local changes do conflict with the upstream changes, and git pull refuses to overwrite your changes. In such a case, you can stash your changes away, perform a pull, and then unstash, like this:

$ git pull
 ...
file foobar not up to date, cannot merge.
$ git stash
$ git pull
$ git stash pop

###Add Dropbox directory as a remote

  • Initalize git repository
git init
git add .
git commit -m "first commit"
  • Initialize git repository on Dropbox folder as remote branch
cd ~/Dropbox/git
git init --bare project.git
  • Add remote to local git repository
cd ~/project
git remote add origin ~/Dropbox/git/project.git
  • set upstream and push
git push -u origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment