Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Git Basics Working With Remote Repositories Pushing and Pulling

The git bash reports for merge conflict but i don't see conflict markers

I've local remote and clone repositories. I've changed the filename2.txt in remote and commited. I've done same thing in the clone of that remote, edited filename2.txt. Now from clone when I tried to git push, error message said you have to pull first.

While pulling changes from remote, another error popped up, to fix the conflicts. Now I've checked filename2.txt on both the repository, but I don't see any conflict markers.

2 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi Samiullah,

The idea behind version control is to avoid situations such as this one, essentially what you've done is created a naming conflict in your local repository because you've already renamed the file on the remote server, instead what you needed to have done is renamed the file locally and pushed that to the remote server.

How to fix it?

Open up a new terminal window or your preferred Git client, next you either want to enter the below command in terminal otherwise in your Git client right click on the conflicted file and revert it back to how it was before it was renamed.

git commit --amend
git reset HEAD filename2.txt
git checkout -- filename2.txt

Don't get scared by these commands, this is what Git clients are doing behind the scenes.

  1. git commit --amend reverts the last commit, basically it tells your local repository not to commit any changes
  2. git reset HEAD filename2.txt resets the file that was changed from the latest working commit, in this case before you renamed the file
  3. git checkout -- filename2.txt takes a copy of the file from the remote server which will overwrite your local changes

If you have a Git client essentially it's just doing this behind the scenes, once that's all done you should be able to run git pull locally and have no conflicts, if you still do then something else other than a naming conflict is wrong.

How to avoid it?

Whenever you're working in version control always work from your local repository which is the cloned copy of your remote repository, it's considered bad practice to make changes directly on the server as they're harder to rollback and they can cause conflict nightmares.

Hope that helps.

git commit --amend did it Thanks Chris for the help