Git merging the same changed appearance file

I inherited some code (from a zip file) from the developer and git initialized, the changes made and the set of checks gradually.

Now the same developer released the same code with its changes and gave me another zip file.

How to merge my changes, do I have my git repository and its latest changes from the second contents of the zip file?

Ideally, I would like to have code that should be my changes and the latest developer changes.

I tried to create branch b1 from my main branch and apply a second zip file to it. transferred these files in the branch and made the git check wizard; git merge b1 '- but I do not get my changes, only its changes in my main branch.

+3
source share
2 answers

It seems that both you and others based their work on the code that you have as the root commit in your repository. So right now you have this:

A - B - C - D (master)

Another developer work is also based on commit A. So, the right place to fix it is disconnected from A.

Start by creating and checking the branch there: git checkout -b his_work <SHA1 of A>(or in gitk, just right-click on the commit and select create branch).

Then, reset it to work and lock it. To be enjoyable, you can do this with help git commit --author="His Name <his.email@somewhere>"to show that it was his job.

Now, check your master ( git checkout master) and merge its branch ( git merge his_work).

In the end, you should:

A - B - C - D - E (master)
 \             /
  X -----------
  (his_work)

Just to explain, here is what you did:

A - B - C - D      -      X (his_work)
         (master) ----> 

, ; : , , .

+5

, , , . . Git , , .

, , , . , . , :

git checkout <first-commit>
git checkout -b b1        // This just names the branch for the later merge
<copy his files from the zip in>
git checkout master
git merge b1

Git , b1 , master "" , .

+1

Source: https://habr.com/ru/post/1738581/


All Articles