Re:Git Tricks: Avoiding merge when dealing with remote confl...
by lazulicurio on Monday October 21, 2019 @07:58PM
(#21318931)
Personally, I prefer to never use git pull, and instead use git fetch then manually merge or rebase as appropriate. It's one more command, but I find it helps me visualize exactly what I want to happen.
[ Parent
| on HN ]
Re:Git Tricks: Avoiding merge when dealing with remote confl...
by sixstringtheory on Monday October 21, 2019 @08:43PM
(#21319217)
I prefer to always use fast-forwarding when pulling, either with `git pull --ff-only` or setting pull.ff to "only" in configuration. This way, if a merge conflict is encountered, it will refuse the pull and you can then do your preferred manual resolution flow of either merging or rebasing. This way I can get the majority of pulls done quickly, because more often than not, I don't have to resolve conflicts (of course YMMV). I also prefer the slightly more verbose output from `git pull --ff-only` vs plain `git pull`.
There's also `git pull --rebase` (mentioned in TFA but not really explained), which sort of combines `git pull --ff-only` followed by a `git rebase` if it failed.
Re:Git Tricks: Avoiding merge when dealing with remote confl...
by juped on Monday October 21, 2019 @09:09PM
(#21319376)
I do this as an advanced user with a strong mental model of git, but I find the easier recommendation to others is to just not use the command - '--ff-only' just becomes another incomprehensible incantation without understanding.
Re:Git Tricks: Avoiding merge when dealing with remote confl...
by juped on Monday October 21, 2019 @09:07PM
(#21319370)
You're correct to do so, since git pull is designed for Linus Torvalds or one of his vice-Linuses to merge a large remote patchset they've already reviewed
Re:Git Tricks: Avoiding merge when dealing with remote confl...
by rinchik on Monday October 21, 2019 @08:19PM
(#21319068)
> It's one more command, but I find it helps me visualize exactly what I want to happen
are you saying that git pull can produce some unwanted artifacts? (e.g. not do exactly what you want it to do?)
Re:Git Tricks: Avoiding merge when dealing with remote confl...
by lazulicurio on Monday October 21, 2019 @08:26PM
(#21319114)
> are you saying that git pull can produce some unwanted artifacts? (e.g. not do exactly what you want it to do?)
Not in the sense that git pull has unpredictable behavior, but I like being able to view the remote history and manually diff against my local branch if there are changes that have been made.
Re:Git Tricks: Avoiding merge when dealing with remote confl...
by jolmg on Monday October 21, 2019 @08:51PM
(#21319277)
Though it's still better to do fetch when you want to compare first, pull outputs the ranges of commits that it's pulling for each branch, so you can just copy and paste that into a diff or log command, too.
I say this because I used to just ignore the output, but then I found that it's useful, too.
So, if git-pull outputs
b3b2007..9bad624 master -> origin/master
I can do `git diff b3b2007..9bad624` or `git log b3b2007..9bad624` to see what I just pulled.