sync files without committing?
I have a project I'm working on and have th开发者_运维知识库e 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 ?
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:
- Make changes on your laptop
- Commit your changes on your laptop
- Push commits to repository on a USB stick
- Pull commit from the USB stick to the repository on your PC
- Make more changes
- Commit them - you might also amend your other commit if you want your changes to be atomic
- 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.
Just Use rsync
command. Make sure you are in your local repo root path, and run:
rsync -a --exclude=.git . root@xxx.xxx.xxx.xxx:[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.
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 :)
精彩评论