Reputation: 49
So I've made the mistake of pushing a project stored in a local repository on my laptop to GitHub and then made some modifications directly to the files in the remote repository on the website itself. Now I can't pull the files from GitHub and I can't push any changes made in the local repository to the remote because both repos have slightly different files. Is there any way I can merge these two repositories so I can keep on pushing changes from the local to the remote?
Upvotes: 1
Views: 1386
Reputation: 177
commit
any changes in your local branch (or reset
them if not required)fetch
from GitHub to your local repositorymerge
the fetched branch (e.g. origin/master
) into your local branchpush
your local branch to GitHubUpvotes: 1
Reputation: 4895
I think your problem is, that you have local files, were are changed and are staying in the working directory. So first step, just must commit your local changes by using the
git commit
command. Now you have a empty working directory and now you can pull from the remote repo by using the
git pull
command. This will fetches a new changes and merge them to your local changes. Only there is no conflicts (changes in the same file in local and remote version). If there are no conflicts, you can push your changes to remote repo, otherwise you need to resolve all conflicts and then you can also push the changes to the remote repo.
After pushing you will have on both (local and remote) the same version.
Upvotes: 2