From 04604da774d09dc48154384c6cef1066beee94e1 Mon Sep 17 00:00:00 2001 From: xnivaxhzne Date: Wed, 26 Jun 2024 16:06:29 +0530 Subject: [PATCH 1/2] Add command for git reset current branch with respect to its remote version --- README.md | 1 + bin/git_reset_current_branch.js | 4 ++++ lib/git_reset_current_branch/index.js | 13 +++++++++++++ package.json | 3 ++- 4 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 bin/git_reset_current_branch.js create mode 100644 lib/git_reset_current_branch/index.js diff --git a/README.md b/README.md index 7e25e08..351e988 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ npm i -g @xniva/git-shortcuts | `glc` | `git show-branch --no-name HEAD` | Copy and Print the last commit message | | `gsf` | `gcm && gpm && git merge --no-commit --no-ff origin/${featureBranch}` | List the changes of a feature branch w.r.t master - for review | | `gma` | `git merge --abort` | Abort the merge | +| `grb` | `git reset --${hardOrSoft} origin/$(git rev-parse --abbrev-ref HEAD)` | Reset the current branch to its remote equivalent | ### Master branch name is configurable: diff --git a/bin/git_reset_current_branch.js b/bin/git_reset_current_branch.js new file mode 100644 index 0000000..71d5974 --- /dev/null +++ b/bin/git_reset_current_branch.js @@ -0,0 +1,4 @@ +#! /usr/bin/env node +import main from "./../lib/git_reset_current_branch/index.js"; + +main(); diff --git a/lib/git_reset_current_branch/index.js b/lib/git_reset_current_branch/index.js new file mode 100644 index 0000000..a488d16 --- /dev/null +++ b/lib/git_reset_current_branch/index.js @@ -0,0 +1,13 @@ +import runCommand from "./../utils/run_command.js"; + +const main = () => { + let isHard = process.argv[2] === "--hard" || process.argv[2] === "-h"; + + const hardOrSoft = isHard ? "hard" : "soft"; + + runCommand( + `git reset --${hardOrSoft} origin/$(git rev-parse --abbrev-ref HEAD)` + ); +}; + +export default main; diff --git a/package.json b/package.json index ac760b6..971e945 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "glc": "bin/git_print_copy_last_commit_message.js", "gr": "bin/git_restore.js", "gsf": "bin/git_see_feature_files.js", - "gma": "bin/git_merge_abort.js" + "gma": "bin/git_merge_abort.js", + "grb": "bin/git_reset_current_branch.js" }, "author": "Kavinkumar R", "license": "MIT", From a59e6f006db2dd8671f1e4e35dc6c04a7a1187d0 Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 26 Jun 2024 10:37:34 +0000 Subject: [PATCH 2/2] 1.5.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 73527ad..61ee971 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@xniva/git-shortcuts", - "version": "1.5.0", + "version": "1.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@xniva/git-shortcuts", - "version": "1.5.0", + "version": "1.5.1", "license": "MIT", "dependencies": { "dotenv": "16.4.5", diff --git a/package.json b/package.json index 971e945..32aa63b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@xniva/git-shortcuts", - "version": "1.5.0", + "version": "1.5.1", "description": "Shortcuts for the commonly used git commands", "repository": "https://github.com/kavinkuma6/git-shortcuts", "bin": {