ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://stegriff.co.uk/upblog/move-last-git-commit-to-a-different-branch/ |
| Last Crawled | 2026-04-07 17:11:02 (1 day ago) |
| First Indexed | 2023-02-06 22:05:17 (3 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Move last git commit to a different branch - SteGriff |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | 06 February 2023
So you committed to
main
instead of your feature branch? Oops! But it’s ok. All commits in git are special little things that are easy to chip up and kick around ⚽
If you need to do any sleuthing first, use
git log
The Process
I already created the target feature branch
If you created the feature branch on remote first (in GitHub or DevOps), run:
git fetch
Checkout the branch where you should have put the commit:
git checkout my-branch
Now merge
main
into it (feels wrong but is right)
git merge main
You can
git push
your feature branch changes at this point, if you want.
I didn’t create the feature branch yet
Ok, so you’re on
main
which has the latest commit that should be in the branch instead. Simply:
git checkout -b my-new-branch
And it will be copy of main including your new commit.
Use
git push -u origin my-new-branch
on your feature branch to push it up to the remote.
Moving main back
Checkout
main
, then move it back however many commits you want:
git checkout main
git reset --keep HEAD~1
And you’re done!
You can use
git log
for your satisfaction.
Commit early, commit often 🦕 |
| Markdown | # [SteGriff](https://stegriff.co.uk/)
## [Blog](https://stegriff.co.uk/upblog)
- [March 2026 Month Notes 04 April 2026](https://stegriff.co.uk/upblog/march-2026-month-notes/)
- [Host a generated static site with docker or disco 30 March 2026](https://stegriff.co.uk/upblog/host-a-generated-static-site-with-docker-or-disco/)
- [I made a Kotlin UDL for Notepad++ 22 March 2026](https://stegriff.co.uk/upblog/i-made-a-kotlin-udl-for-notepad/)
- [Feb 2026 Month Notes 25 February 2026](https://stegriff.co.uk/upblog/feb-2026-month-notes/)
- [January 2026 Month Notes 13 February 2026](https://stegriff.co.uk/upblog/jan-2026-month-notes/)
Next & Previous
- [Adding cache-busting chunk-hashes to Vue CLI output JS](https://stegriff.co.uk/upblog/adding-cache-busting-chunk-hashes-to-vue-cli-output-js/)
(newer)
- [I fixed my Yamaha PSS-A50](https://stegriff.co.uk/upblog/i-fixed-my-yamaha-pss-a50/)
(older)
# Move last git commit to a different branch
06 February 2023
So you committed to `main` instead of your feature branch? Oops! But it’s ok. All commits in git are special little things that are easy to chip up and kick around ⚽
If you need to do any sleuthing first, use
```
git log
```
## The Process
### I already created the target feature branch
If you created the feature branch on remote first (in GitHub or DevOps), run:
```
git fetch
```
Checkout the branch where you should have put the commit:
```
git checkout my-branch
```
Now merge `main` into it (feels wrong but is right)
```
git merge main
```
You can `git push` your feature branch changes at this point, if you want.
### I didn’t create the feature branch yet
Ok, so you’re on `main` which has the latest commit that should be in the branch instead. Simply:
```
git checkout -b my-new-branch
```
And it will be copy of main including your new commit.
Use `git push -u origin my-new-branch` on your feature branch to push it up to the remote.
### Moving main back
Checkout `main`, then move it back however many commits you want:
```
git checkout main
git reset --keep HEAD~1
```
And you’re done\!
You can use `git log` for your satisfaction.
Commit early, commit often 🦕
2014–2025 SteGriff - Stephen Griffiths
[Home](https://stegriff.co.uk/)
[About](https://stegriff.co.uk/#about)
[Upblog](https://stegriff.co.uk/upblog)
[Blogroll](https://stegriff.co.uk/blogroll)
[100% Human-written](https://stegriff.co.uk/upblog/my-ai-policy/)
â›… |
| Readable Markdown | 06 February 2023
So you committed to `main` instead of your feature branch? Oops! But it’s ok. All commits in git are special little things that are easy to chip up and kick around ⚽
If you need to do any sleuthing first, use
```
git log
```
## The Process
### I already created the target feature branch
If you created the feature branch on remote first (in GitHub or DevOps), run:
```
git fetch
```
Checkout the branch where you should have put the commit:
```
git checkout my-branch
```
Now merge `main` into it (feels wrong but is right)
```
git merge main
```
You can `git push` your feature branch changes at this point, if you want.
### I didn’t create the feature branch yet
Ok, so you’re on `main` which has the latest commit that should be in the branch instead. Simply:
```
git checkout -b my-new-branch
```
And it will be copy of main including your new commit.
Use `git push -u origin my-new-branch` on your feature branch to push it up to the remote.
### Moving main back
Checkout `main`, then move it back however many commits you want:
```
git checkout main
git reset --keep HEAD~1
```
And you’re done\!
You can use `git log` for your satisfaction.
Commit early, commit often 🦕 |
| Shard | 11 (laksa) |
| Root Hash | 10116534853926180411 |
| Unparsed URL | uk,co,stegriff!/upblog/move-last-git-commit-to-a-different-branch/ s443 |