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?

random
  • 9,774
  • 10
  • 66
  • 83
MaACAn
  • 313
  • 3
  • 9
  • You need to commit your changes before you can pull them to another repo. – kayrick Jul 16 '14 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](http://www.gitguys.com/topics/shared-repositories-should-be-bare-repositories/). – Sascha Wolf Jul 16 '14 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. – MaACAn Jul 16 '14 at 16:26
  • 1
    possible duplicate of [Merge git repo into branch of another repo](http://stackoverflow.com/questions/21353656/merge-git-repo-into-branch-of-another-repo) – random Jul 16 '14 at 16:41
  • Or http://stackoverflow.com/questions/277029/combining-multiple-git-repositories – random Jul 16 '14 at 16:42

1 Answers1

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 '

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • 1
    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. – MaACAn Jul 16 '14 at 16:28