Hello. I have two repositories

Checker.rep

  • 1Ch.file
  • 2Ch.file
  • 3Ch.file

Main.rep

  • Checker.folder

Tell me how to move files from the Checker.rep repository to the Checker.folder folder so that the commit history is saved and you can delete the remaining empty Checker repository?

  • one
    Possible duplicate . - Sasha Chernykh
  • one
    @SachaBlack If you follow the instructions given there, the three marked files will be in the root of this repository, and not in the folder inside it. Of course, they can be transferred by a separate commit ... But this is a bad style. Each commit should be self-sufficient. - D-side
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

Since these are two separate unrelated stories, in order to link them, you have to do a merge . Confusing is the fact that the branches in different repositories, and how to do the merger, is unclear ... it is fixable , although not quite as the link. One repository can be tightened to another.

Just do not pull from another repository is not worth it, because in this case, files from the root of one repository will fall into the root of another, and the goal is slightly different. Therefore, instead of pull will do what it consists of: fetch + merge .

In Main.rep

 git remote add checker путь/к/Checker.rep # указать источник git fetch checker # только скачать (!) коммиты # warning: no common commits # <- ну, это ожидаемо # remote: Counting objects: 5, done. # remote: Compressing objects: 100% (4/4), done. # remote: Total 5 (delta 1), reused 0 (delta 0) # Unpacking objects: 100% (5/5), done. # From путь/к/Checker.rep # * [new branch] master -> checker/master git merge checker/master --no-commit 

--no-commit interest is the --no-commit flag (for this purpose, a pull round was started), which, after the merge procedure is completed, will stop Git so that you can correct the results. It's time to throw the files that arrived during the merge into the desired folder:

 git mv *Ch.file Checker.folder 

That's all, achieved the desired state.

 git commit 

Is done.