5/16/2023 0 Comments Git fetch vs pull![]() ![]() Therefore, by default, pulling from the remote is not a harmless operation: it can creates a new commit sha that didn’t exist before! I find that this behavior confuses Git novices, because what feels like it should be a harmless download operation actually changes the commit history in unpredictable ways.Ĭonsider the following situation. There’s the problem: git pull performs a merge, which often creates a merge commit. In its default mode, git pull is shorthand for git fetch followed by git merge FETCH_HEAD. However, what the command actually does is explained in the next sentence. Incorporates changes from a remote repository into the current branch. The description of git pull in git pull -help looks rather harmless. If you get nothing else out of this blog post, it should be that running the following simple command will save you many headaches as a novice Git user. ![]() In this blog post, I will advocate for using the -ff-only option for git pull, and furthermore setting it as the default option for git pull. Often, there is one root cause: Git trying to be helpful and performing operations on your repository that you did not intend. Having introduced Git to many dozens of people, first as a teaching assistant and now as a professional software engineer, I have seen many of the mistakes that Git novices commonly make. Like many great things, if you are new to Git, it takes trial and error before you can come to appreciate its power and simplicity. Git is a simple, elegant version control system.
0 Comments
Leave a Reply. |