Issue
Say I want to run the command:
git reset --hard origin/abc
where abc
is my current branch. How can I programmatically insert the current branch into the command instead of having to run git branch --show
, copying the result, and pasting into the reset
command?
Solution
You can target the upstream of any branch with <branch>@{u}
, and the upstream of your current branch with @{u}
(more details than you want to in git help gitrevisions
)
So you can reset to your upstream with :
git reset --hard @{u} # if on Windows: quote "@{u}" on Powershell and cmd.exe
Answered By - LeGEC Answer Checked By - Katrina (WPSolving Volunteer)