Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git reset --hard fails if branch name contains slashes

Tags:

git

According to How to reset my local repository to be just like the remote repository HEAD you can set your local branch to match the remote branch by

git reset --hard origin/<branch_name>

which works fine for branches that don't have slashes in their names.

For my remote branch 'topic/something' with the command

git reset --hard origin/topic/something

I get the following error:

fatal: ambiguous argument 'origin/topic/something': unknown revision or path not in the working tree.

What is the correct syntax for branch names containing slashes? Thanks.

like image 338
Jakob Wanner Avatar asked Nov 11 '22 04:11

Jakob Wanner


1 Answers

I found what was missing. I only did

git fetch origin topic/something

before I tried the git reset --hard command. But I needed to do

git fetch --all

as well. Then

git reset --hard origin/topic/something

worked. Thanks for your help.

like image 90
Jakob Wanner Avatar answered Nov 12 '22 19:11

Jakob Wanner