git 如何在 2 台计算机上针对一个 github 存储库进行编码?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6012073/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I code against one github repo on 2 computers?
提问by Zandorf
I have two computers from which I want to contribute to one github repo. How can I accomplish this?
我有两台计算机,我想从中为一个 github 存储库做出贡献。我怎样才能做到这一点?
采纳答案by Nick Berardi
To keep both repositories in sync you should to pull the latest changes to your machine whenever you start working on the code.
为了保持两个存储库同步,您应该在开始处理代码时将最新更改拉到您的机器上。
To do this you want to execute
为此,您要执行
git pull
...which is usually set up to pull from the default remote (origin) to your current branch. Git might complain if this isn't the case, and so the longer version will work as well:
...通常设置为从默认远程(源)拉到当前分支。如果不是这种情况,Git 可能会抱怨,所以更长的版本也可以工作:
git pull origin {branch_name}
Note:this is the same process that you would use if two or more people were working on the same repo. Which is essentially what is happening, instead of two different people working on the same repository, you have two different machines working on the same repository.
注意:如果两个或更多人在同一个 repo 上工作,这与您将使用的过程相同。这基本上就是正在发生的事情,不是两个不同的人在同一个存储库上工作,而是有两台不同的机器在同一个存储库上工作。
If you are starting out fresh on a new machine all you need to do is clone the repo to it first:
如果你是在一台新机器上重新开始,你需要做的就是首先将 repo 克隆到它:
git clone {remote_url}
You get this url from your GitHub repo's home page. This command will make a complete working copy of the repo in a subdirectory.
您可以从 GitHub 存储库的主页获取此 URL。此命令将在子目录中制作完整的 repo 工作副本。
回答by hammar
You need to clone the repository on your second computer.
您需要在第二台计算机上克隆存储库。
git clone [email protected]:myusername/myrepo.git
Now you can use git pull
and git push
to keep your local repository in sync with the one on GitHub.
现在,您可以使用git pull
,并git push
与在GitHub上一个让您的本地资源库同步。
回答by Zaid_Code36
Starting working on another machine do the next:
开始在另一台机器上工作,请执行以下操作:
1- Creat a new directory on your local machine to have your work saved to it.
1- 在您的本地机器上创建一个新目录以将您的工作保存到其中。
2- from that newly created directory, open Bash( assuming that you already have git installed on your machine) by clicking the right mouse click and you will see (Git Bash here).
2- 从新创建的目录中,单击鼠标右键打开 Bash(假设您的机器上已经安装了 git),您将看到(此处为 Git Bash)。
3- on Bash type git clone (your Repo URL OR ssh key). press enter
3- 在 Bash 上键入 git clone (您的 Repo URL 或 ssh 密钥)。按回车
4- just done. :)
4-刚刚完成。:)
回答by beagan
You want to checkout the repository on the other computer, you do not want to fork it.
你想签出另一台计算机上的存储库,你不想分叉它。