Github overwrites old project

I have a Java Project on Github, now I changed it to using Gradle and he had to change the whole project structure. To do this, I created a whole new Java project and copied the code files. As I expected, I can't just merge the project with the lead branch on Github. Is there any way to overwrite the branch of the old master? I do not need the old structure, the code is the same. I also do not want to duplicate the code in different folders. How can i solve this?

Summary

I want to rewrite the old code with the new code, because it is a complex multi-project solution with a common code and multi-platform interface, and there are many conflicts that would be much easier to resolve if I just saved the new code and discarded the old code.

+4
source share
2 answers

Here is my suggestion -

  • Import the old master branch from the source
  • Switch the branch and name the branch "new master" or something.
  • Make changes to the "new master"
  • Now combine the new master and the master on the local
  • Conflict Resolution
  • Build it if you can click it.

Or -

1) Just make the changes in new master 
2) Push it as a new branch 
3) Use it as the origin for your future forks.

you can abandon the old master, so you will also have a history of changes, the only thing that will change is your origin URI

to rename a branch -

  git branch -m old_branch new_branch
  git push origin new_branch
+2
source

, , master , - new-master. new-master master , new-master, . :

  • git checkout master
  • git merge -X theirs new-master

master , new-master. master github. .

-X theirs git -merge.

ours
    This option forces conflicting hunks to be auto-resolved cleanly by
    favoring our version. Changes from the other tree that do not conflict
    with our side are reflected to the merge result. For a binary file, 
    the entire contents are taken from our side.

    This should not be confused with the ours merge strategy, which does
    not even look at what the other tree contains at all. It discards
    everything the other tree did, declaring our history contains all
    that happened in it.

theirs
    This is the opposite of ours.

, github.

git push --force origin master

. :

, , . , . , .

+3

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


All Articles