A
A
albertalexandrov2018-09-26 09:37:46
git
albertalexandrov, 2018-09-26 09:37:46

How to get the end situation from the start situation?

Hi all!
Please tell me how to use the commands in git from the start situation (Fig. 15) to make the end situation (Fig. 16)?
5bab274d97d8a682943899.jpeg
I myself solved this problem using a temporary branch from a C3 commit like this:
1. Switch to a C3 commit and create a temporary TEMP branch:
$ git checkout C3
$ git checkout –b TEMP
3. Perform changes and commit:
$ git commit –am “C10
4. Switch to branch F3 and rebase to TEMP (resolve conflicts if any): $ git
checkout F3
$ git rebase TEMP C9': $ git branch –f TEMP C9' 6. Delete the TEMP branch:
5bab28bf442f5088957478.png
$ git branch –d TEMP
7. Move commit C4:
$ git cherry-pick C4

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-10-04
@dlnsk

There are options. I came up with this, rather extravagant:

$ git checkout F1
$ git reset --hard HEAD^ (первые две команды можно заменить на git checkout -B F1 C3)
$ git commit –am “C10”
$ git checkout F3
$ git rebase F1
$ git cherry-pick C4
$ git checkout -B F1 C4

And all the branches will be in place.
Say that I deleted C4 in the second step ... well, yes, I deleted it! ;) Only it does not change anything, everything will work.
You just need to remember that by deleting commits and moving branches you are not actually deleting anything (unless, of course, you run a garbage collection). Those. we, for example, can easily restore the lost commits C8 and C9 if we execute Well, if you have already forgotten what exactly you deleted, then it will help you.
git reflog

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question