I've created a branch named <title>-changes
by:
git checkout -b <title>-changes
and did a commit on that branch. Later I checkout to another-branch
started working on another-branch
. Now I want to checkout to the previous branch (<title>-changes
) but I can't do that now through:
git checkout <title>-changes
I know this is a simple issue but can't crack. I tried:
git checkout \<title>-changes
git checkout /<title>-changes
git checkout '<title>-changes'
but no luck. Getting errors like:
$error: pathspec '<title' did not match any file(s) known to git.
$bash: title: No such file or directory
$error: pathspec '<title>-change-pdp ' did not match any file(s) known to git.
Git imposes the following rules on how references are named: They can include slash / for hierarchical (directory) grouping, but no slash-separated component can begin with a dot . or end with the sequence . lock . They must contain at least one / .
To be precise, renaming a remote branch is not direct – you have to delete the old remote branch name and then push a new branch name to the repo. Step 2: Reset the upstream branch to the name of your new local branch by running git push origin -u new-branch-name .
You have to escape both <
and >
because bash treats them as special symbols.
In order to do that, prepend the backward slash \
to each of them:
git checkout \<title\>-changes
This is what I did to test this, and it worked.
mkdir test
cd test/
git init
git branch \<title\>-changes
touch empty
git add empty
git commit -m "Added empty file"
git branch \<title\>-changes
git checkout \<title\>-changes
touch second
git add second
git commit -m "Added second empty file"
git checkout -b another-branch
touch third
git add third
git commit -m "Added third empty file"
git checkout \<title\>-changes
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