简体   繁体   中英

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. I have already performed git clone and a clone resides on my computer. How would I keep my experimenting from affecting the master branch?

Note: I'm using Windows.

It doesn't matter if you use windows or any other operating system. 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. If you do not want to affect the local master branch then - just create another branch ( git checkout -b <branch_name> ) and work there.

I think this book is a nice read to get started with 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.

The best thing to do in your case is to fork the Linux master branch on github and then clone it. You can then play with your master branch and do whatever you want to do with it. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM