简体   繁体   中英

Git push local branch to repo

I'm trying to push my local branch (Dev) up to my git repo so that when someone else clones the repo, they will have the Dev branch as a local one.

So far, when you clone the repo and run git branch -a you get this:

master
remotes/origin/Dev
remotes/origin/master

but what I want the person to get is this:

Dev
master
remotes/origin/Dev
remotes/origin/master

I've tried git push --all but that didn't help. I've tried a few other things but I can't remember them all and I'm willing to try them again.

Also, My Dev local branch tracks to the Dev remote branch.

There is no provision in Git to do that. The other person will have to create a local copy of your branch by:

git checkout -b Dev origin/Dev

what this does is to create a local branch named 'Dev' which tracks the remote branch 'origin/Dev'. So essentially, both you and the other person have individual copies of the remote branch. And whenever you or the other person push , it gets synced with the remote branch and the other person gets the changes while pull ing. This is how Git is supposed to be used.

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