Home > OS >  Getting the state of a commit, and reapplying it in another
Getting the state of a commit, and reapplying it in another

Time:12-22

Setup:

----- master branch 
                   \
                    \
                     sprint branch
                                  \
                                   my branch --> commit a --> commit b 

How can a commit c be created with the changes before a was pushed (both a and b are already pushed)?

(a and b are trial and error commits)

CodePudding user response:

In git, commits don't "belong to" branches; instead, branches are just a pointer to a commit. Commits contain a snapshot of the repository, and zero or more (usually one) parent pointers, from which history can be read backwards.

So if I understand you correctly, you probably don't want to create a commit, you just want to create a branch (a named pointer) to carry on working on top of an existing commit.

You can do that with the git branch command, as long as you know the commit hash you want it to point at. You can find that by running git log.

  • Related