简体   繁体   中英

Git and branches

ok so apparently to create a new git branch on the remote repository we need:

git push origin origin:refs/heads/sandbox
git fetch origin
git checkout --track -b sandbox origin/sandbox
git pull

Now if I want to switch back to the master branch I can just do

git checkout master

If I want to switch back to sandbox after going back to master, do I need

git checkout --track -b sandbox origin/sandbox

or just

git checkout sandbox

git checkout sandbox will work. When you did the checkout -b sandbox origin/sandbox , you set up a local branch named sandbox which will track the remote origin/sandbox . To get the latest changes from upstream into your local copy, do git pull when on the sandbox branch.

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