Moosa
Moosa

Reputation: 3216

Merging Git files with local file

I'm a newbie to working with git. I made some changes to my code directly on Git. Then I copy pasted code from Git to my local file. Then made more changes to the local file and tried to merge with the file on git. I'm getting errors in my command line (when i go git commit) saying the files are not in sync and it doesn't let me commit changes.

I went back and copy/pasted git code to my local file so that's where I am. What do I do next to sync my files and be able to commit from my local file to git?

Upvotes: 1

Views: 34

Answers (1)

raviolicode
raviolicode

Reputation: 2175

Try fetching the changes from GitHub first.

I assume you already cloned your repository locally, so you need to pull the changes using:

git pull origin master

If you are using the master branch.

If you get the changes first, you shouldn't run into conflicts. If you didn't pull the changes first, you need to tell git which change are you keeping, if the one that's on GitHub (in the remote), or the local changes.

If you have trouble with resolving conflicts, check the article on resolving merge conflicts.

Upvotes: 1

Related Questions