Code of some branchs disappeared after merge

Asked

Viewed 235 times

0

I have a very strange situation (probably vacilo right...) here in my repository.

I have a branch of DEV and several other of Features and bugs.

With each branch of Feature or bug, we merge with branch DEV.

We worked on 2 Devs on this project, me, always before doing the merge, make a pull in the Dev branch. Ai then do the merges. The other dev apparently did one git fecth before merging, I have no idea if it implied anything, but some of the branches I had already merged into DEV simply don’t feature the code in the DEV branch.

I turned the remote git log -all, which, if I understand correctly, shows the branchs that are part of the currently selected branch, so with the DEV branch selected, when running this command, there are the branchs whose codes are missing.

I need to understand what we did wrong...

I have the "lost code" in the respective branchs (local and remote), so I selected one of the branchs and when trying to merge again, gives a message saying that it is updated (Already up to date.)

Anyone can help?

  • Private server, Github or similar?

  • Local is local, remote is remote, in remote vc can have branchs that do not exist in remote and vice versa, there is not much q help, maybe you looking back the log until you see the point that such missing branch no longer "exist" or be "logged in".

  • private bitbucket @Jonathandetoni

  • Maybe I expressed myself badly @Guilhermenascimento, it was not the branch that disappeared, I meant that the code of some branches is not in the DEV Branche, which is the one that "receives" the merges. wanted very much to understand how we did this shit..., but as important as, is to know how to redo these merges, because I have the branches with the codes I need, but when trying to merge with Dev, says that it is already updated.

  • Take a look at Bitbucket, see if the branchs are still there, if it is, problem is only local. Ai falls in @Guilhermenascimento’s comment

  • @Jonathandetoni, the branches of Features and bugs added are local and remote. knows what I can do to merge again?

  • Still recommend @Guilhermenascimento’s method of reviewing the log backwards, so you can find the right time where the shit was done

  • If they’re not in the branch then you didn’t commit them, if you didn’t commit then they don’t exist and they never existed and you can’t get something you didn’t save (cc @Jonathandetoni)

  • @Guilhermenascimento, man, thanks for the help, but this is pretty crazy for someone who doesn’t know much like me..., the commits are in the remote. I develop in a local environment, then develop several branches, and commit and merge with DEV each time q finishes the job. Ai generated a new Dev-based Ranche, and followed the game, until last Friday, the other Dev merged with the branch he was developing and then "disappeared" the codes that had been merged (merge).

  • Dude, a recommendation, start using tools like git-flow, make it easier to work, are few commands and do everything right. For those not used to it, it’s a great entrance!

  • If they are on the remote then the code is there, does another local branch as the name RECOVER and makes the rollback to the point that you need to take those files, copy everything you need, delete the branch, take what you copied and adjust in your editing branch, ready :)

Show 6 more comments

2 answers

2

Analyzing specific merge problems are complicated without understanding exactly what commands were given, what order were carried out, if there was a conflict, if anyone is allowed to do so force push, whether users can commit directly to the branch dev, if what disappeared was code within existing classes, even new classes have disappeared, etc.

Since git is a very flexible tool, there are several different ways to get the same results (good or not).

But better than giving the fish, is teaching to fish. And we can also draw some conclusions from what you said.

Like the merge has been identified as already done in the dev, this means that the merge occurred but something was lost during this merge or after it. The greatest possibility I see is that the merge was realized, some conflict has occurred and those who resolved the conflict chose to consider only the changes to their branch.

How to analyze

Try to identify a point in your repository’s history where the code was still in the branch by git log:

git log

From him, comb through the history by looking for the moment the code disappeared. You can do this by checking directly for each commit in the history and viewing the code from that moment in the repository:

git checkout eR43yUi

(to return to HEAD, do git checkout dev)

If you have any questions between the changes of two commits, you can see the differences between commits with the git diff:

git diff eR43yUi..7yaoljM

See the difference between commits before and after each merge performed, as it was probably at this point that the problem occurred.

If you see any commit mentioning any kind of revert, see if this commit was not the cause of the problem. Someone might have reverted some commit from the "merged" branch with git revert after merging.

2

For the record in case someone goes through something similar.

We concluded that one of the team devs made a new Feature and the basis of this was an old branch, without the updates of the last few weeks and sent them "killing" everything the other devs did.

To solve the problem, I followed the idea of Guilherme Nascimento, I did a "rollback" up to an update before the branch that "killed" the changes, and used the command:

git checkout HEAD~1

Where 1 represents how many commits you want to back the pointer on HEAD.

By: https://brorlandi.github.io/git-desfazendo-commits

Thank you to everyone who helped.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.