A
A
Alexey Nikolaev2015-02-05 13:23:18
PHP
Alexey Nikolaev, 2015-02-05 13:23:18

Is it possible in GIT to change the parent of the very first commit in a branch (change the original branch)?

Hello!
There is a branch, let's call it branch-B, and a branch branch-A. branch-A is based on master, and branch-B is based on the latest commit of branch-A. Now, is it possible to make branch-B change its genealogy and make it look like it was created from the master branch?
I would be grateful for advice, thanks.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Nikolaev, 2015-02-05
@Heian

Found a solution.
To change the parent branch from which the branch we need to branch to master, you need to execute
Instead of ~2, there can be any desired number (the number of commits in the branch + 1) to shift the pointer to the last commit in master. After that, you can safely make any other commit.

M
Max, 2015-02-05
@AloneCoder

read about rebase

K
kintawer, 2019-07-22
@kintawer

git rebase master

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question