git hints

By Jen Richmond

September 28, 2022

I am getting pretty good at avoiding git merge conflicts by always remembering to pull before I push when using github. But the terminal in RStudio has been giving me this hint for a while and I have been ignoring it.

I think this hint is trying to help me but I don’t know what rebase or fast-forward means… to google…

This post suggests that I should only use git pull -ff, going as far as setting -ff as a global config setting.

Apparently git pull is actually a two step thing (git fetch + git merge). First, it fetches the content from the remote and then it merges that content into your local. That is USUALLY fine… especially if you are working alone and nothing has changed about your remote repo since the last time you pulled. In this case, your local will be ahead of your remote and git pull will be fine.

But if you are using git to collaborate and your team member has pushed some changes to the files you are working on, you can find yourself with a merge conflict.

The git pull –ff-only command will fetch and merge content from the remote repo, only if it can be done be done by “fast-fowarding”- that is, without creating new commits. This will only happen if the remote and local haven’t diverged. If they have it will give you a warning.

Apparently in my use case, when I am mostly working with myself and the remote is unlikely to have diverged from the local, the default option (rebase false) will work fine.

Twitter friends were helpful here…

Posted on:
September 28, 2022
Length:
2 minute read, 326 words
See Also: