From 2cb25a5aea137a9f2a60e8c52eb03feb029258f4 Mon Sep 17 00:00:00 2001 From: Maheshkumar P <67100964+Maheshkumar-novice@users.noreply.github.com> Date: Mon, 2 Dec 2024 22:31:01 +0530 Subject: [PATCH] Remove extra new lines from the command snippets --- git/intermediate_git/working_with_remotes.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/git/intermediate_git/working_with_remotes.md b/git/intermediate_git/working_with_remotes.md index a02fa55defa..bc214f2d71a 100644 --- a/git/intermediate_git/working_with_remotes.md +++ b/git/intermediate_git/working_with_remotes.md @@ -20,12 +20,10 @@ If you haven't updated your local branch, and you're attempting to `git push` a You might perform a brief query and find the command `git push --force`. This command overwrites the remote repository with your own local history. So what would happen if we used this while working with others? Well, let's see what would happen when we're working with ourselves. Type the following commands into your terminal, and when the interactive rebase tool pops up remove our commit for `Create fourth file`: ```bash - git push origin main git rebase -i --root git push --force git log - ``` Huh, that's interesting. We can’t find our fourth file on our local system. Let's check our GitHub repository to see if it's there. @@ -35,18 +33,15 @@ Oh no, we just destroyed it! In this scenario, the danger - you could potential Let's consider a different scenario: ```bash - touch test4.md git add test4.md && git commit -m "Create fifth file" git push origin main git log - ``` We look at our commit message and realize *oops*, we made a mistake. We want to undo this commit and are once again tempted to just force the push. But wait, remember, this is a **very dangerous command**. If we're ever considering using it, always check if it's appropriate and if we can use a safer command instead. If we're collaborating with others and want to *undo* a commit we just made, we can instead use `git revert`! ```bash - git revert HEAD git push origin main ```