Development led to the master. Then I did validation on the validation branch and gui on the gui branch. It was necessary to put it on githabs with different branches. And I was in master and validation and gui, and only after that I sent it to the githab. How can I fix it?

It is important for me that it is on the githaba that they appear as different branches. Therefore, if there is a way to divide them visually on the site itself, while leaving them merged on the computer, then this method will also work for me.

The code in these branches suits me, and there were no conflicts when merging. I want to share, just because the people who will study the project on the githabe must clearly understand where the master branch ended. Those. Only a small part of the project should be in the master. And I got the whole project in master.

    2 answers 2

    First, losing git code is not so easy. If anything, you always have git reflog to recover a lost commit . And you can always make a backup of the current branch with the help of git branch backup (arbitrary name).

    Next, you need to roll back the master branch to a commit before merging: git reset --hard commit-name . More: How to return (roll back) to an earlier commit?

    It’s just not possible to push a branch because there are commits on the githaba, which are not in your branch, so the automatic fast-forward merge will not work. git push -f will help. This command replaces the contents of the remote branch.

    It remains to push the remaining branches. In order not to specify a local and remote branch each time, you can once assign a remote upstream branch to a local branch:

     git push -u origin master git push -u origin validation git push -u origin gui 

    You can push all the branches at once (in general, everything in refs/heads/ ):

     git push -u --all origin Branch master set up to track remote branch master from origin. Branch validation set up to track remote branch validation from origin. Branch gui set up to track remote branch gui from origin. 
    • one
      Thank you very much, very informative! - Alexander Elizarov

    You can go back to the previous commit using git reset mixed <коммит>

    • No it's not that. My problem is not that those 2 branches are not visible. I'll post them when necessary. My problem is that the wizard displays the entire project, well, because I’ve drafted the whole project there. And in master there should be only that part of the project that was developed in master. That is, only those commits that were there before the merge. - Alexander Elizarov
    • git reset <нужный комит> commit git reset <нужный комит> will return to the desired commit reset use - Yaroslav
    • Yes thank you. Only need to do with the parameter mixed. And this will only cancel the merger. And on github to cancel, I made a git push origin master --force - Alexander Elizarov