From 3a242ba45acc8c409fafd2393920af127e4c5ccd Mon Sep 17 00:00:00 2001 From: srdusr Date: Wed, 21 Dec 2022 23:57:07 +0200 Subject: Add more information about resetting the local main branch to remote repository --- tools/git.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/git.md b/tools/git.md index a926b00..b79677a 100644 --- a/tools/git.md +++ b/tools/git.md @@ -49,6 +49,9 @@ #### Use git subtree to sync other repos into dotfiles 1. First make sure dotfiles is up-to date or commit/push/reset all changes otherwise this error message will show: `Working tree has modifications. Cannot add.` + ```bash + $ config reset --hard origin/main + ``` Also NOTE: the prefix (subdirectory in which you will add the subtree) cannot already exist therefore delete/backup locally. @@ -102,13 +105,14 @@ Push the changes/commits onto repo: ```bash $ git push -u origin ``` -Delete the most recent commit, keeping the work you've done: +Reset the local main branch to remote repository aka... +Delete the most recent commit, destroying the work you've done: ```bash -$ git reset --soft origin/ +$ git reset --hard origin/main ``` -Delete the most recent commit, destroying the work you've done: +Delete the most recent commit, keeping the work you've done: ```bash -$ git reset --hard origin/ +$ git reset --soft origin/ ``` Allow unrelated histories when two unrelated projects are merged/unaware of each other's existence: -- cgit v1.2.3