I cloned my entire GitHub repository to a local computer using:
git clone [email protected]:my_account_name/my_repository_name.git
Suppose the branches I had on the remote repository were foo and bar. When I do:
git branch -r
the remote branches stored on my local computer are listed with the names:
origin/foo
origin/bar
(And with git branch -a, they appear with remotes/ further prefixed.) When I work on the branches on my local computer, I want to refer to the branches without the origin/ prefix. For each branch, I can probably do like:
git branch -m origin/foo foo
to rename the branch, but I actually have a lot of branches, and do not want to do it manually one by one. Is there a way to get rid of these origin/ (or remotes/origin/) prefix for multiple remote branches on the local computer at once?
Just do git checkout foo. That's it.
You're not supposed to rename or work in the origin/* branches, they track the remote repository's state. You don't work in them directly, you create your local copies.
Checking out a branch which doesn't exist locally but does exist remotely creates this branch automatically for you, so just do a checkout but omit the origin/ part.
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