From 9dee1fdfb818de20b9cc0f175274ce99854cd98b Mon Sep 17 00:00:00 2001 From: srdusr Date: Sat, 17 Dec 2022 22:36:54 +0200 Subject: Add reset commits and toggle unrelated-histories --- tools/git.md | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tools/git.md b/tools/git.md index 99f1dad..f3c6122 100644 --- a/tools/git.md +++ b/tools/git.md @@ -69,24 +69,37 @@ - - - ## Basic commands -Intialize a git repository in the root of the folder. +Intialize a git repository in the root of the folder: ```bash $ git init ``` -See which files git knows exist. +See which files git knows exist: ```bash $ git status ``` -Add a new file to the repo. +Add a new file to the repo: ```bash $ git add ``` -Create a commit with a message about the commit. +Create a commit with a message about the commit: ```bash $ git commit -m ``` -Push the changes/commits to our repo. +Push the changes/commits to a repo: ```bash $ git push -u origin main ``` +Delete the most recent commit, keeping the work you've done: +```bash +$ git reset --soft origin/main +``` +Delete the most recent commit, destroying the work you've done: +```bash +$ git reset --hard origin/main +``` +Allow unrelated histories when two unrelated projects are merged/unaware of each +other's existence: +```bash +$ git pull origin main --allow-unrelated-histories +``` - - - -- cgit v1.2.3