Half the time I encounter a problem on Git, it’s because I’m in the wrong folder. This is the worst kind of git K-hole, because it’s so easy to fix but also so easy to overlook when you’re first getting the hang of (g)it.
Today, I kept trying to add the readme file, commit it, and then push it to Github. In response, git would barf out…
This drove me bonkers because I was certain that I had edited the readme file and fixed the conflict. But I hadn’t looked closely enough at the error message. Is says the file name is “../README.md,” which to the careless and untrained eye can easily be mistaken for README.md. However, the difference between the two is vast. The former “../README.md” file name specifies that the file i needed to fix one was directory above my current directory. I had been fixing the wrong readme file the whole time.
With that discovery, I simply had to follow these steps:
1. cd .. (to move up one directory)
2. subl README.md (to open the file in Sublime and resolve the merge conflict)
3. git add . (to track all the files in the correct directory, including readme.md)
4. git commit -m “Finally! Resolve merge conflict!”
5. git push origin master
Phew. Here’s to knowing which directory you are in at all times!