Git: how to change active branch on remote repository?

帅比萌擦擦* 提交于 2019-12-06 14:33:23

If the remote repository is just a sharing point, a bare repository, you'd be better off just communicating the branch having the code to the other developers.

In a later comment you however imply that the remote repository is a checkout served as a website. You should note that even if you pushed to the currently active branch, pushing doesn't automatically check out the HEAD of that branch.

If you don't have any shell access to the remote machine, I don't think it's possible to do what you want. If you have any influence there, you could ask to set up a post-receive hook to check out the new branch.

Of course, if you have ssh access, just

ssh remote.net "cd /path/to/repo; checkout fix_vouchers"

My View. There is nothing called an active branch in remote. It is up to you to decide whether a branch is active or not.

Coming to your your scenario. You can make a push a new branch to remote called releaseCandidate or release or devBranch. And then tell everyone to use that as the testing/development branch.

But if your problem is like other developers are using some particular script to checkout , you may need to change that script.

No you can't set the active branch on the remote bare repository with a local command.

The active branch is the one pointed to by HEAD. This is the branch some of git's commands view as the default branch for the repository, such as git clone <url> <name> will checkout the default branch by default.

If you have command line access to the remote repository, the git symbolic-ref command can be used to set which branch is default -- see: Setting the default git branch in a bare repository.

That said, there is nothing special about any particular branch once checked out. Any branch can be shared with another developer by having them create a branch tied to the remote branch specifically with a git checkout -b <branch> command, where is the name of the remote branch you want to share with them. This will create a branch on their local repository that is tracked against the remote branch.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!