Code Monkey home page Code Monkey logo

lukathis.github.io's People

Contributors

xuchi16 avatar

Watchers

 avatar

lukathis.github.io's Issues

Git Operations

https://www.xuchi.pro/git-operations/

Split 1 commit into 2

Sometimes, we mistakely commit multiple files in one single commit while it actually did 2 things.
In this case, if we only hope to cherry-pick part of them to another branch, we have to split this commit into 2.
To realize this, we can use rebase command with the interactive mode.

The overall logic is just reoccur the whole change journey and you can arrange the stages as you want.

Here’re steps which can also be found here:
Break a previous commit into multiple commits https://stackoverflow.com/questions/6217156/break-a-previous-commit-into-multiple-commits

Start an interactive rebase with below command where  is the commit you want to split. In fact, any commit range will do, as long as it contains that commit

git rebase -i <commit>^



Mark the commit you want to split with the action “edit”, yes, just change it in vim mode from “pick” to “edit”


Input “x” to trigger the rebase


When it comes to editing that commit, run this command. The effect is that the HEAD is rewound by one, and the index follows suit. However, the working tree stays the same

git reset HEAD^



Now add the changes to the index that you want to have in the first commit. You can use git add (possibly interactively) or git gui (or both) to do that


Commit the now-current index with whatever commit message is appropriate now


Repeat the last two steps until your working tree is clean


Continue the rebase with command

git rebase --continue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.