Clone git repo to non-empty folder

I have a big C project under git. Someone has the same C project, but it does not use git.

We both started with the same baseline, but I just did git init / git add . and started using git.

I would like to merge my changed git changes into another branch and init git in my project folder so that we synchronize and use git.

How do you do this in git?

+4
source share
2 answers

Your friend needs $ git init , $ git add . and $ git commit -a its code.

Both of you must have the same remote repository: $ git remote add origin <your-repository-url> (with GitHub, it looks like https://github.com/username/repository.git )

Your friend should $ git pull origin master (he will combine the remote branch with his local one)

It just needs $ git push -u origin master so you can $ git pull , and that should be fine

+5
source

First, clone your repo into an empty directory.

Then, in the new repo, create and check out a new branch to work with friends. The branch point should be the last commit in which you both had the same source (maybe your initial commit).

Then you copy your sources to a new tree. Git status / diff should now show the changes it made.

Make a git commit on this branch, and you should have one repo from both development branches.

Make a git merge master to merge your work (which is in the master branch) into a new branch of your colleagues. Have fun resolving conflicts, commit, and you're done.

If you want the changes to be returned to your own repo, you can pull or fetch from your repo using the ssh:// URL if you have ssh access to the machine or file:/// if you can see it directly.

+1
source

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


All Articles