Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby: Working With Remotes: Remove extra new lines from the command snippets #29146

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions git/intermediate_git/working_with_remotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
```
Expand Down
Loading