Make an existing Git branch track a remote branch?

前端 未结 22 3032
执念已碎
执念已碎 2020-11-21 07:16

I know how to make a new branch that tracks remote branches, but how do I make an existing branch track a remote branch?

I know I can just edit the

22条回答
  •  旧时难觅i
    2020-11-21 07:57

    Editing .git/config is probably the easiest and fastest way. That's what the Git commands for handling remote branches are doing, anyway.

    If you don't want to muck with the file by hand (and it's not that hard to do), you can always use git config to do it...but again, that's just going to edit the .git/config file, anyway.

    There are, of course, ways to automatically track a remote branch when using git checkout (by passing the --track flag, for example), but these commands work with new branches, not existing ones.

提交回复
热议问题