Working with GIT – Part 3 (Problems with pull push fetch and merge)

While working with git, git pull and git push make up for the majority of the commands we run.

git pull

This command is a shortcut for git fetch and git merge. While many developers advocate for using the git fetch and the git merge command, for the novice of users running without too much complexity, git pull does the job.

Sometimes the git pull command is not able to do the task at hand, due to complexities, in which case, the git fetch and git merge are very very required.

git push

This command is required to push the local changes to the remote server. Please check Part 1 for more details.

Problem – fatal: refusing to merge unrelated histories

This happens when two projects pointing to the same remote location have started their histories differently. The gir pull command has been taught to cinsider these hsitories differnt and not allow merge. So to force git to run the command succesfully, pass the –allow-unrelated-histories option to the command.

So a command which earlier was

git pull origin master

would now be

git pull origin master --allow-unrelated-histories

Read previous entries on git:

Part 1: Creating my first git project

Part 2: Working with branches

Murari Mohan Nayak (Murari M.)

Leave a Reply

Your email address will not be published. Required fields are marked *