sync files without committing?
Asked Answered
H

3

9

I have a project I'm working on and have the following set up : one server with my git repos, one desktop pc and a laptop.

I work on my project sometimes on the desktop, sometimes on my laptop.

How can I sync my files between the desktop pc and the laptop without commiting changes to the server ?

Hoi answered 3/2, 2011 at 11:40 Comment(7)
The phrase "one server with my git repos, one desktop pc and a laptop" is really weird. Presumably if you are working on the laptop and the desktop, then they also have repos. Stop thinking of the repositories on the server as being different than the repository on the desktop or the pc. They are all equal.Teacher
@william I don't agree. If someone clone the projet, it will be from "the server", not from the laptop.Parthenogenesis
@Parthenogenesis Unless they clone the project from the laptop. The whole point of git (one of the major points, anyway) is that there is absolutely no difference between the two repositories.Teacher
We all agree with this, but misuse of langage are sometime usefull and better than long explanation...Parthenogenesis
@william if there are uncommitted changes on the laptop, and "they are all equal" then the uncommitted changes should be on the server and desktop, right? If not, then they are not equal, and the uncommitted changes would need to be synced.Sentimentality
@jdk1.0 No, "equal" does not mean identical.Teacher
@william, lol. Okay. 3.0 = 3.1, close enough, you win. I'm still waiting for my uncommitted changes to "equal" the ones on my other machine... ;-) I think I think I understand your point, though, that all git repos are created equal; none is the "server."Sentimentality
T
3

You can more or less directly pull and push between your "clients", i.e. PC and laptop. The transport may be a direct connection like SSH or HTTP. But you can also use another repository on external media, that may be a USB stick, an external hard drive or even a service like Dropbox.

That way your workflow could look like this:

  1. Make changes on your laptop
  2. Commit your changes on your laptop
  3. Push commits to repository on a USB stick
  4. Pull commit from the USB stick to the repository on your PC
  5. Make more changes
  6. Commit them - you might also amend your other commit if you want your changes to be atomic
  7. Push your final commits to the repository on the server

Be aware that you'll always need to commit your changes locally before you can push them to another repository. It seems like you come from another SCM system like Subversion where committing always means "make the changes visible on the server and for everyone". Git works different, commits are only local before you push them.

Testudo answered 3/2, 2011 at 11:45 Comment(2)
I'll give dropbox a try. Another question regarding this though: instead of creating a new repo in the dropbox directory is it ok to have a working directory inside it that would be synced through dropbox and only push to one repo (the one on my server) ?Hoi
Yes, that would work too. But Dropbox would sync every change you make to working copy. So this might be a bit of a problem.Testudo
A
3

Just Use rsync command. Make sure you are in your local repo root path, and run: rsync -a --exclude=.git . [email protected]:[Your Remote Path]

you can fix your code in local, and rsync it. When the code can be deploy, then commit the deploy issue.

you can config your ssh remote alias in ~/.ssh/config file, google to know how to config it. Then your command will be: rsync -a --exclude=.git . [remote-alias-name]:[Your Remote Path] And needn't enter password.

Alfy answered 25/9, 2016 at 2:15 Comment(0)
I
1

You could use a service like Dropbox if you need a "quick and dirt" solution. I have a couple of repo in my Dropbox dir :)

Ibiza answered 3/2, 2011 at 11:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.