Search code examples
gitgithubtortoisegitgit-fetch

Tortoise Git not fetching latest commit


I am having some trouble with Tortoise Git and GitHub not fetching the latest commit whenever I click "fetch." Whatever it does fetch Tortoise Git places inside of a folder titled as the remote repo inside of my workspace on Eclipse. If I try a merge, it fails. To solve this, I had the idea of replacing my Eclipse src folder with the src folder from the fetch. I did not, however, check to make sure that the files fetched were from the most recent commit. This resulted in me deleting all of my most recent changes and setting me back a day.

I found this question to be somewhat helpful (git fetch not fetching latest commits), but I do not understand the procedures that Tortoise Git and GitHub use to fetch from the remote repository.

What can I do to avoid this issue in the future and how does a git fetch and merge truly work?

Thanks much for the help.


Solution

  • I will recommend you run git pull instead of git fetch, because git pull does a git fetch followed by a git merge, that is if your intention was to git fetch then you git merge.

    • When you use pull, Git tries to automatically do your work for you. It is context sensitive, so Git will merge any pulled commits into the branch you are currently working in. pull automatically merges the commits without letting you review them first. If you don’t closely manage your branches, you may run into frequent conflicts.

    • When you fetch, Git gathers any commits from the target branch that do not exist in your current branch and stores them in your local repository. However, it does not merge them with your current branch. This is particularly useful if you need to keep your repository up to date, but are working on something that might break if you update your files. To integrate the commits into your master branch, you use merge.

    This should help I guess.

    You might want to go through this SO question: What is the difference between 'git pull' and 'git fetch'?