Skip to content

Commit 49d973d

Browse files
authored
Add aliases git rhu and git frhu (#32)
* Add aliases git rhu and git frhu For git reset --hard @{upstream} and git fetch && git reset --hard @{upstream} respectively. Resolves #25
1 parent 522cf1d commit 49d973d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ Alias to create a commit and pre-fill the commit message with the most recent co
5656

5757
See [Recover failed Git commit message](https://salferrarello.com/recover-failed-git-commit-message/)
5858

59+
### `git rhu` (and `git frhu`)
60+
61+
Alias for `git reset --hard @{upstream}` to discard local changes and reset the branch to match the upstream (`@{upstream}`) branch.
62+
63+
`git frhu` does the same thing but performs a `git fetch` first to ensure we have the latest version of the upstream branch.
64+
65+
See [Replace Local Git Branch with Branch on GitHub](https://salferrarello.com/replace-local-git-branch-with-branch-on-github)
66+
5967
### `git track-origin-same-branch-name`
6068

6169
Alias for `git branch --set-upstream-to=origin/$(git rev-parse --abbrev-ref HEAD)`.

gitconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
}; f"
4747
please = push --force-with-lease
4848
recover-rejected-commit = "!f() { git "commit -e --file=$(git rev-parse --git-dir)/COMMIT_EDITMSG"; }; f"
49+
rhu = reset --hard @{upstream}
50+
frhu = !git fetch && git reset --hard @{upstream}
4951
track-origin-same-branch-name = !git branch --set-upstream-to=origin/$(git rev-parse --abbrev-ref HEAD)
5052
[branch]
5153
sort = -committerdate

0 commit comments

Comments
 (0)