3

I'm new to git and GitHub. This far, I managed to setup my environment so that I can push commits to GutHub via the git program.

I own two computers, which share files using Dropbox. That's where I keep my development projects too. What I wanted to know is: is there a way to use git, GitHub and Dropbox altogether? I read guides to use git and Dropbox without stepping through GitHub.

In a practical example: say I am in a project folder on my laptop (the project folder is on Dropbox). I git push origin master and everything goes fine, updated on GitHub. Now on my desktop I have the updated files, synched via Dropbox.

Should I git pull the most recent version from GitHub anyway?

Edit

Lots of people think I'm asking how to use git along with Dropbox. I'm not.

What I'm asking is how to keep your work inside Dropbox, use git anyway and still be able to push to GitHub sometimes.

whatyouhide
  • 15,897
  • 9
  • 57
  • 71
  • 1
    You don't need dropbox. Simply clone the repo on the second computer. That's what git is all about ... – bryanmac Apr 20 '13 at 15:57
  • I would discourage you from using git and Dropbox together at all, actually. http://stackoverflow.com/a/5851299/139010 http://stackoverflow.com/q/2199637/139010. If you have GitHub, or any other remote, you simply don't need Dropbox. – Matt Ball Apr 20 '13 at 15:58
  • possible duplicate of [Using Git and Dropbox together effectively?](http://stackoverflow.com/questions/1960799/using-git-and-dropbox-together-effectively) – Fred Foo Apr 20 '13 at 15:58
  • @MattBall ok, so I have to `push` changes from one computer and then, before starting to work on the other computer, I have to `pull` changes there. Am I right? – whatyouhide Apr 20 '13 at 15:59
  • It feels like a bad idea sometimes, but I personally use Git and Dropbox together. You don't have to pull changes; `.git` is synchronized too. – Ry- Apr 20 '13 at 16:00
  • @whatyouhide that is correct. Are you really switching so much that it's a burden? I personally prefer to push _more,_ not less, if for no other reason than backing up my work. – Matt Ball Apr 20 '13 at 16:01
  • @minitech yep, that's what I thought. I just liked this way to go because I have my repos on GitHub, which is cool, but I'm still able to sync a repo even if I don't push it to GitHub. – whatyouhide Apr 20 '13 at 16:02
  • @larsmans my problem is not about using git with Dropbox, I'm adding the GitHub variable to the problem! – whatyouhide Apr 20 '13 at 16:03
  • 1
    Github is for sharing code so you're best to only push whenever you're at a natural 'checkpoint' (i.e. everything presumed working). – Glitch Desire Apr 20 '13 at 22:39

1 Answers1

3

OK, I'll split this up into its constituent questions:

1. Should I use git pull anyway?

If these two computers are the only ones you use to modify this code base, and nobody else is pushing to the remote repository, there'd be no reason (other than good practice) to run git pull in this instance. Your Dropbox is doing the job of keeping your code synchronized and your Github will be serving your code to the world at large.

2. How to git push anyway?

Dropbox won't affect this, your .git folder and .gitignore file are the components which define what will be pushed. Dropbox will be invisible to the whole process UNLESS you try to git push half way through a Dropbox synchronize job in which case you could end up with some consistency issues.

3. Are there any advantages?

I don't think Dropbox really gives you very much here as you're using Github. Having said that, I use a similar setup with a NAS drive connected to my home computers, I just use my svn (I've been meaning to move to bzr but keep failing to do it) to update when I'm on the road.

Glitch Desire
  • 14,632
  • 7
  • 43
  • 55