如何使用git同步代码而不提交? [英] How to use git to sync code without committing?

查看:1075
本文介绍了如何使用git同步代码而不提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中使用egit来在两个位置之间使用bitbucket上的一个存储库来同步我的代码。



我希望能够处理任一位置的代码。我通常做的是在一天结束时提交更改。



有另一种方式我应该这样做,因为我最终提交了很多提交我仍然在工作的代码仍然损坏?



我以为这个想法是你只是在代码工作时才提交。什么是最佳实践,所以我可以更新存储库中的代码,而不提交,只有代码运行时提交?

解决方案

如果使用Linux终端,可以使用 rsync 命令。以下答案是从我的其他答案复制



只需使用 rsync 命令。确保你在你的本地回购根路径,并运行:

  rsync -a --exclude = .git。 root@xxx.xxx.xxx.xxx:[您的远程路径] 

您可以修复代码本地和rsync它。当代码可以部署时,然后提交部署问题。



您可以在〜/ .ssh / config中配置ssh远程别名code>文件,google知道如何配置它。那么你的命令将是:

  rsync -a --exclude = .git。 [remote-alias-name]:[您的远程路径] 

无需输入密码。 / p>

I use egit in Eclipse to sync my code between two locations using a repository on bitbucket.

I want to be able to work on the code from either location. What I usually do is commit the changes at the end of the day.

Is there another way I should be doing this, as I end up with a lot of commits for code that I'm still working on that is still broken?

I thought the idea was that you are meant to only commit when the code is working. What is best practice so I can update the code in the repository without committing, and only commit when the code is working?

解决方案

If you use Linux Terminal, you can use rsync command. The follow answer is copy from my other answer

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.

这篇关于如何使用git同步代码而不提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆