Skip to content
Closed
Show file tree
Hide file tree
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
38 changes: 0 additions & 38 deletions README.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@
git rebase --continue
```

At this point, you can edit any of the files in your project to make any additional changes. For each change you make, you'll need to perform a new commit, and you can do that by entering the `git commit --amend` command. When you're finished making all your changes, you can run `git rebase --continue`.
At this point, you can edit the files in your project to make the changes you want to include in the current commit. Stage your changes with `git add`, then run `git commit --amend` to update the current commit rather than create a separate commit.

If you only want to change the commit message, run `git commit --amend` without changing the staged file contents.

When you're finished, run `git rebase --continue` to resume the rebase.

Git then gets to the `reword 4ca2acc` command. It opens up your text editor one more time, and presents the following information:

Expand All @@ -128,18 +132,21 @@

## Pushing rebased code to GitHub

Since you've altered Git history, the usual `git push origin` **will not** work. You'll need to modify the command by "force-pushing" your latest changes:
Since you've rewritten Git history, a regular `git push` may be rejected. To update the remote branch, you may need to force-push:

```shell
# Don't override changes
$ git push origin main --force-with-lease
$ git push --force-with-lease

Check failure on line 138 in content/get-started/using-git/using-git-rebase-on-the-command-line.md

View workflow job for this annotation

GitHub Actions / lint-content

Dollar signs used before commands without showing output

Dollar signs used before commands without showing output
```

# Override changes
$ git push origin main --force
This command pushes the current branch to its configured upstream. If you want to specify the remote and branch explicitly, use:

```shell
$ git push origin HEAD --force-with-lease

Check failure on line 144 in content/get-started/using-git/using-git-rebase-on-the-command-line.md

View workflow job for this annotation

GitHub Actions / lint-content

Dollar signs used before commands without showing output

Dollar signs used before commands without showing output
```

> [!WARNING]
> Force pushing has serious implications because it changes the historical sequence of commits for the branch. Use it with caution, especially if your repository is being accessed by multiple people.
This command pushes the current branch (HEAD) to the corresponding branch on origin.

The --force-with-lease option is safer than --force because it checks the expected remote branch state and can refuse to update the branch if the remote has changed unexpectedly. However, it does not eliminate every risk of overwriting others’ work. Before force-pushing to a shared branch, check for collaborators’ changes and coordinate with them as needed.

## Further reading

Expand Down
Loading