🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 20 (from laksa171)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

📄
INDEXABLE
✅
CRAWLED
9 hours ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.flother.is/til/git-move-commit-to-branch/
Last Crawled2026-04-11 22:22:51 (9 hours ago)
First Indexed2023-03-03 01:37:40 (3 years ago)
HTTP Status Code200
Meta TitleHow to move your most recent Git commit to a new branch — Flother
Meta DescriptionFlother is the online home of Matt Riggott, a programmer and map-maker living in ReykjavĂ­k, Iceland.
Meta Canonicalnull
Boilerpipe Text
If you’re anything like me you’ll have found yourself writing new code and accidentally committing it to the default branch (usually master or main ). This might be alright for your personal repos, but when you’re working in a larger team and collaborating on a project using a branch-based workflow (like GitHub flow ), then you need to move that commit to a new branch before you push the code. One way to do this would be to ‘undo’ the commit: rewind your repository history so it’s as if that commit never happened, but with your local files still modified. However, if you do that, you lose the detailed commit message you spent ten minutes writing (you did write a good commit message, didn’t you?). No, what you want to do is create a new branch that includes your latest commit, and then remove the commit from your default branch. So what you’ve done so far is commit your new code to the master branch by accident: git commit # Oops To fix that, you should branch off from the tip of master and then move master back one commit: git switch - C new-branch git switch master git reset -- soft HEAD^ That last line, git reset --soft HEAD^ , will remove the last commit from master and the files you changed will still be modified but staged. (If you have more than one commit to remove, you can use HEAD~3 instead of HEAD^ , where 3 is the number of commits you want to remove. You actually have loads of options available .) Now you’ve cleaned that up, you can unstage the modified files and then push the new branch: git reset . git switch new-branch git push - u origin new-branch And now no-one’s any the wiser. You have a clean master branch, a new branch with your new code, and you’re free to carry on adding new commits to the branch .
Markdown
[Flother](https://www.flother.is/) # How to move your most recent Git commit to a new branch Today I learnt … 2 March 2023 If you’re anything like me you’ll have found yourself writing new code and accidentally committing it to the default branch (usually `master` or `main`). This might be alright for your personal repos, but when you’re working in a larger team and collaborating on a project using a branch-based workflow (like [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow)), then you need to move that commit to a new branch before you push the code. One way to do this would be to ‘undo’ the commit: rewind your repository history so it’s as if that commit never happened, but with your local files still modified. However, if you do that, you lose the detailed commit message you spent ten minutes writing (you did write a good commit message, didn’t you?). No, what you want to do is create a new branch that includes your latest commit, and then remove the commit from your default branch. So what you’ve done so far is commit your new code to the `master` branch by accident: ``` git commit # Oops ``` To fix that, you should branch off from the tip of `master` and then move `master` back one commit: ``` git switch -C new-branch git switch master git reset --soft HEAD^ ``` That last line, `git reset --soft HEAD^`, will remove the last commit from `master` and the files you changed will still be modified but staged. (If you have more than one commit to remove, you can use `HEAD~3` instead of `HEAD^`, where `3` is the number of commits you want to remove. You actually have [loads of options available](https://git-scm.com/docs/git-rev-parse#_specifying_revisions).) Now you’ve cleaned that up, you can unstage the modified files and then push the new branch: ``` git reset . git switch new-branch git push -u origin new-branch ``` And now no-one’s any the wiser. You have a clean `master` branch, a new branch with your new code, and you’re free to carry on [adding new commits to the branch](https://xkcd.com/1296/). - [Git](https://www.flother.is/tags/git/ "See all pages tagged Git") - [Home](https://www.flother.is/) - [Blog](https://www.flother.is/blog/) - [Today I Learnt](https://www.flother.is/til/) - [Travelogue](https://www.flother.is/travelogue/) - [Podcast](https://www.flother.is/podcast/) - [Categories](https://www.flother.is/categories/) - [Tags](https://www.flother.is/tags/) - [GitHub](https://github.com/flother) - [OpenStreetMap](https://www.openstreetmap.org/user/flother) - [Flickr](https://www.flickr.com/photos/riggott) © 2023
Readable Markdown
If you’re anything like me you’ll have found yourself writing new code and accidentally committing it to the default branch (usually `master` or `main`). This might be alright for your personal repos, but when you’re working in a larger team and collaborating on a project using a branch-based workflow (like [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow)), then you need to move that commit to a new branch before you push the code. One way to do this would be to ‘undo’ the commit: rewind your repository history so it’s as if that commit never happened, but with your local files still modified. However, if you do that, you lose the detailed commit message you spent ten minutes writing (you did write a good commit message, didn’t you?). No, what you want to do is create a new branch that includes your latest commit, and then remove the commit from your default branch. So what you’ve done so far is commit your new code to the `master` branch by accident: ``` git commit # Oops ``` To fix that, you should branch off from the tip of `master` and then move `master` back one commit: ``` git switch -C new-branch git switch master git reset --soft HEAD^ ``` That last line, `git reset --soft HEAD^`, will remove the last commit from `master` and the files you changed will still be modified but staged. (If you have more than one commit to remove, you can use `HEAD~3` instead of `HEAD^`, where `3` is the number of commits you want to remove. You actually have [loads of options available](https://git-scm.com/docs/git-rev-parse#_specifying_revisions).) Now you’ve cleaned that up, you can unstage the modified files and then push the new branch: ``` git reset . git switch new-branch git push -u origin new-branch ``` And now no-one’s any the wiser. You have a clean `master` branch, a new branch with your new code, and you’re free to carry on [adding new commits to the branch](https://xkcd.com/1296/).
Shard20 (laksa)
Root Hash2267687846180591220
Unparsed URLis,flother!www,/til/git-move-commit-to-branch/ s443