Reputation: 733
I had a git repository hosted on GitHub. I recently switched machines and copied the files manually to the new machine rather than doing git pull
, kind of forgot to do so. Now I made some changes and initiated a new git repository while adding the GitHub one as remote. I need to know how can I merge the two repositories i.e keep my commit history from the GitHub one and also keep my changes made to the new one? Thank you!
Upvotes: 1
Views: 902
Reputation: 11
Since you have already set remote url you can either create a new branch to store the changes and push it.Later you can merge the branches when necessary. Or Since you have created local repository and set remot-url you can directly push to your repository after commiting. Hope this helps.
Upvotes: 1
Reputation: 17262
If there are not too many changes (just a single commit's worth), this is really easy:
git clone ssh://... newfolder
newfolder
newfolder
and push. At this point, your Github history is correct. Delete the old folder, name the new one whatever you'd like.Upvotes: 1
Reputation: 6144
You just need to rebase your new branch with upstream branch. You can do this by setting an upstream branch for your new branch with git branch -u origin/my_branch
(assuming the remote you added is called origin
and you are currently on your new branch) then execute git pull --rebase
to rebase your branch. After that you can git push
your new commits on top of your existing commits on GitHub.
Upvotes: 2