简体   繁体   English

克隆远程git存储库以供本地使用,而不会干扰远程分支

[英]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.

相关问题 没有本地克隆的远程存储库上的git操作 - git operations on remote repository without local clone git clone远程到远程,没有本地副本 - git clone remote to remote without local copy 在不更改本地存储库的情况下撤消远程分支上的git push? - Undo a git push on the remote branch without changing local repository? git将本地分支推送到远程存储库 - git push local branch to remote repository Git-如何在不添加远程的情况下将本地分支重置为远程分支 - Git - How to reset local branch to remote branch without adding a remote 我可以克隆远程git存储库,但可以引用本地存储库以提高效率吗? - Can I clone a remote git repository but reference a local repository for efficiency? git 如何克隆远程存储库特定分支的子目录? - How to git clone a subdirectory of a particular branch of a remote repository? 是否可以从远程存储库 git clone 但使用本地存储库中的对象来节省带宽? - Is it possible to git clone from a remote repository but use objects from local repository to save bandwidth? `git clone` 是否复制远程存储库上的每个分支? - Does `git clone` copy every branch on the remote repository? 从本地分支到远程分支的Swtich没有弄乱GIT存储库 - Swtich from local branch to remote branch without mess up the GIT repository
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM