git:correcting-git-commits
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| git:correcting-git-commits [2025/07/27 18:39] โ created odefta | git:correcting-git-commits [2026/02/11 15:40] (current) โ [How to Do It (Command Line)] odefta | ||
|---|---|---|---|
| Line 19: | Line 19: | ||
| ==== How to Do It (Command Line) ==== | ==== How to Do It (Command Line) ==== | ||
| - | |||
| - **Step 1: Amend the Commit Locally** | - **Step 1: Amend the Commit Locally** | ||
| Run the following command. This will open your default text editor to let you change the message. | Run the following command. This will open your default text editor to let you change the message. | ||
| Line 29: | Line 28: | ||
| git commit --amend -m " | git commit --amend -m " | ||
| </ | </ | ||
| - | |||
| - **Step 2: Push the Changes to the Server** | - **Step 2: Push the Changes to the Server** | ||
| Because you have changed a commit that already exists on the remote server, you must force the update. **Always** use the safer `--force-with-lease` option. | Because you have changed a commit that already exists on the remote server, you must force the update. **Always** use the safer `--force-with-lease` option. | ||
| <code bash> | <code bash> | ||
| + | # Short version (when the branch already has upstream configured) | ||
| + | git push --force-with-lease | ||
| + | |||
| + | # Full version (explicitly specify remote and branch) | ||
| git push --force-with-lease origin < | git push --force-with-lease origin < | ||
| </ | </ | ||
| + | <note tip> | ||
| + | ๐ก **Tip:** In most cases you can use the short version. Git will automatically use the configured upstream for the current branch. | ||
| + | </ | ||
| < | < | ||
| The < | The < | ||
| </ | </ | ||
| - | |||
| --- | --- | ||
| - | |||
| ===== 2. Combining Multiple Commits (Squash) ===== | ===== 2. Combining Multiple Commits (Squash) ===== | ||
git/correcting-git-commits.1753641569.txt.gz ยท Last modified: by odefta
