3

I have two local Git repositories. I cloned one from the other with the command:

git clone /path/to/local/repo/1

I made a couple of changes to each Git repository. Now I want to merge/update the changes of local_repo_1 to local_repo_2 (i.e. in this scenario, local_repo_1 is like a remote git repo that I want to pull the changes from). Is there a way to do this?

I have tried the following:

git add --all
git commit -m "message"
git fetch /path/to/local/repo/1
git pull

I get the response "Already up to date". So how do I update my local Git repo from another git repo? Is there a way to do this?

5
  • You need to commit your changes before you can pull them to another repo. Commented Jul 16, 2014 at 10:32
  • On a sidenote: you should never use a usual repository as a remote. Instead create a bare repository. Take a look here. Commented Jul 16, 2014 at 10:34
  • I did add and commit my changes on both repos, but I still didn't get the updated files on the second git repo. Commented Jul 16, 2014 at 16:26
  • 1
    possible duplicate of Merge git repo into branch of another repo Commented Jul 16, 2014 at 16:41
  • Or stackoverflow.com/questions/277029/… Commented Jul 16, 2014 at 16:42

1 Answer 1

2

Why not using branches? you can achieve the same thing but working on different branch rather then new repo.

Once you done you must commit your changes and them merge them together.

But once again - use branches instead of new repository.

create branch: git checkout -b <new_branch>, make your local changes on this branch and then git add ..., git commit .... and once you done with it merge them together `git merge '

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your answer. I cannot use branches because the first git repo is in a shared folder, and I don't want the work done on the second git repo to be logged on the first git repo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.