How to avoid conflict when I want to delete all files from git repo and then add new files

(Editing the question :)

I have 2 repositories in github, these repositories are http://github.com/abc.git and http://github.com/xyz.git .

Now the repository "abc.git" has become the main repo for the project. After about a month of development, we found that we can do better by making reusable code. Therefore, we decided to create a new repo for the reusable code base of the general code, i.e. xyz.git. So now we have

  • abc.git (very project-specific code + external module + code that we want to rewrite)
  • xyz.git (we made reusable code + external module)

Now the code that we made reusable, basically we added some new files, deleted some old files and modified in xyz.git. This code originally comes from the "we want to rewrite" code from abc.git.

So far so good, I hope :)

Now we have 2 options

  • create a new repo, say project.git, add a new remote repo, i.e. xyz.git, and merge and select the files we need from abc.git. So, in terms of commands, the following

    • the whole process of creating a github repository and add a README file. (this is my project.).
    • git remote add xyz git @ github.com: xyz.git
    • git checkout -b xyz
    • git pull xyz master
    • git status
    • git check wizard
    • git merge xyz
    • git commit -a
    • git push origin master

project.git, xyz.git + README, abc.git( , )

  1. , , , - abc.git xyz.git. .

    • git rm -r * ( abc.git)
    • git commit -m
    • git push origin master ( abc.git , .gitmodules .git)

    • git remote add xyz git @github.com: xyz.git

    • git checkout -b xyz
    • git pull xyz master

. 2 ( , - ).

, , git log -l .

, , , , . : , ? , , - .

.

+3
2

, , . : , , xyz - ( ) abc.

, , ... . , - . ( , github repo):

$ git clone git://github.com/rails/rails.git monster
$ cd monster
$ git fetch git://github.com/madrobby/scriptaculous.git master:old
$ git branch
    * master
      old
$ ls
    [ looks like rails ]
$ git checkout old
$ ls
    [ looks like scriptaculous ]
$ git checkout master
    [ looks like rails again ]

, xyz abc, git filter-branch ( --parent-filter), abc "old" .

, , , . .

0

, , . , . . Git , , .

, , , .

0

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


All Articles