Today I had to work with a remote branch called origin/}__test_syntax_error_in_simpack_settings
. I wanted to create a tracking branch for it.
I had to type:
git branch }__test_syntax_error_in_simpack_settings origin/}__test_syntax_error_in_simpack_settings
I didn't have autocompletion on the first argument, only on the second. I don't like typing. Is there a faster way to do this? The main barrier is having to type the name of the new local tracking branch. Is there a way to tell Git, "create a tracking branch with the same name as origin/whatever
?"
To create a new local branch based on a remote branch, use the "-track" option in the branch command. You can also do this by using the "checkout" command. If you want your local branch to have the same name as the remote branch, you only need to specify the name of the remote branch.
Checking out a local branch from a remote branch automatically creates what is called a tracking branch. Tracking branches are local branches that have a direct relationship to a remote branch. If you're on a tracking branch and type git push , Git automatically knows which server and branch to push to.
New Branches The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.
Remote-tracking branches are references to the state of remote branches. They're local references that you can't move; Git moves them for you whenever you do any network communication, to make sure they accurately represent the state of the remote repository.
git checkout -t -b whatever origin/whatever
or short
git checkout -t origin/whatever
Something to read: http://git-scm.com/docs/git-checkout
I'd do this in bash:
git branch {,origin/}}__test_syntax_error_in_simpack_settings
Sidenote: you seem to have very unusual branch names that might create problems in shells unless properly escaped. Consider renaming your branches, to save yourself some typing and problems the easy way (the lowhanging fruit :))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With