Can I map local branches to remote branches with different prefixes in git?

不打扰是莪最后的温柔 提交于 2019-12-03 12:21:07

If you can, I suggest you use the same branch names locally & remotely. Then git push will push all of your local branches to corresponding branches in the central repository.

To use different prefixes in local and remote repos, you need to add a mapping to your config file each time you create a new feature branch. The command to set up the mapping for topic/BRANCH_NAME is

 git config remote.origin.push refs/heads/topic/BRANCH_NAME:michael/BRANCH_NAME

In your [remote "origin"] section, add one line per mapping. Including master to master.

push = refs/heads/master:master
push = refs/heads/topic/feature:michael/feature

I'm not sure how to do it with the git-config command.

Be aware that from now on, all branches are pushed at the same when you do a straight git push (with no params).

Would you care to explain why you don't keep the same branch names locally and remotely?

You can map your branch to different tracking branch on the remote with something like this:

git remote add heroku git@heroku.com:YOURAPPNAME.git
git checkout -b heroku -t heroku/master

Your config ends up similar to what @Paul suggests (a tad "simpler" actually).

See this gist (with tweaks by me) for usage steps that work well for me https://gist.github.com/2002048.

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