salcode / salcode-git

My Git configuration.
MIT License
3 stars 1 forks source link

Alias for git fetch && git reset --hard @{u} #25

Closed salcode closed 5 months ago

salcode commented 8 months ago

i feel like it would be cool if git had “git pull —force” (the same as git push —force but instead it resets your local branch to wherever the remote is currently)

of course you can accomplish the same thing with git reset but it’s something I fairly often want to do

https://social.jvns.ca/@b0rk/111851540697408119

I like this idea. Typically, I accomplish this with

git fetch && git reset --hard @{u}

but something closer to git pull --force would be nice.

Maybe git pull-force or perhaps it makes more sense to stay away from git pull, in which case maybe git resetu or git ureset

salcode commented 6 months ago

In #30 we talked about git rhu for git reset --hard @{u}, perhaps we want to do that and git frhu for git fetch && git reset --hard @{u}

salcode commented 6 months ago

Note: @{u} is shorthand for @{upstream}. We should use @{upstream} in our alias

When you have a tracking branch set up, you can reference its upstream branch with the @{upstream} or @{u} shorthand. So if you’re on the master branch and it’s tracking origin/master, you can say something like git merge @{u} instead of git merge origin/master if you wish.

from 3.5 Git Branching - Remote Branches