[英]Clone remote git repository for local use without interfering with the remote branch
I want to clone the public Linux master branch from Kernel.org so I can experiment with the code on my personal computer without affecting the public branch. 我想从Kernel.org克隆公共Linux master分支,这样我就可以在个人计算机上试验代码而不会影响公共分支。 I have already performed
git clone
and a clone resides on my computer. 我已经执行了
git clone
并且克隆驻留在我的计算机上。 How would I keep my experimenting from affecting the master branch? 如何避免实验影响master分支?
Note: I'm using Windows. 注意:我正在使用Windows。
It doesn't matter if you use windows or any other operating system. 使用Windows或任何其他操作系统都没有关系。 If you have your local clone of a remote repository you can do whatever you want and as long as you don't use
git push origin master
the remote repository will not be affected. 如果您拥有远程存储库的本地克隆,则可以执行任何操作,并且只要不使用
git push origin master
,远程存储库就不会受到影响。 If you do not want to affect the local master
branch then - just create another branch ( git checkout -b <branch_name>
) and work there. 如果您不想影响本地
master
分支,则-只需创建另一个分支( git checkout -b <branch_name>
)并在那里工作即可。
I think this book is a nice read to get started with Git. 我认为这本书是Git入门的不错的阅读书 。
I'm not entirely sure I understand what you want to avoid. 我不太确定我了解您要避免的事情。 If you have a clone, all work you do is only local to your clone.
如果您有克隆,则您所做的所有工作仅在您的克隆本地。 You are not able to break something in the remote repository (you don't have push permissions anyway).
您无法破坏远程存储库中的某些内容(无论如何您都没有推送权限)。
The remote tracking branch origin/master
will (after performing git fetch
) always contain the current state of the official public repository. 远程跟踪分支
origin/master
git fetch
(在执行git fetch
)将始终包含官方公共存储库的当前状态。
The best thing to do in your case is to fork the Linux master branch on github and then clone it. 在您的情况下,最好的做法是在github上分支Linux master分支,然后将其克隆。 You can then play with your master branch and do whatever you want to do with it.
然后,您可以与master分支一起玩,并做任何您想使用的分支。 In either case, nothing you do on your local master will affect the remote until you explicitly (try to) push to the remote, so not to worry.
在这两种情况下,在您明确(尝试)推入遥控器之前,对本地主机所做的任何操作都不会影响遥控器,因此不必担心。 Also, you can always create another branch where you can try stuff - this is true with any project you want to work on.
另外,您始终可以创建另一个分支,在其中可以尝试使用其他东西-对于要处理的任何项目都是如此。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.