The reason I use “git fetch && git rebase” instead of “git pull” is because a senior dev told me it was better this way when I was an intern, he didn’t tell me why and now I do stuff for the only sake of not looking stupid 🫠
@_RustyRooster
Nowadays, I work from forks, so I do the following commands to sync my main branch with upstream
git fetch upstream main
git reset --hard upstream/main
This way I fetch only one branch instead of pulling all the garbage.
I used to do
git pull --ff-only --prune
Which is…
@_RustyRooster
Fetch only accepts the incoming changes but doesn't update your branch, whereas git pull rebase will update your branch with everyone's changes...
@_RustyRooster
At my company we squash prs when merging, so I just do “git fetch && git merge origin/main”.. I dont mind the merge commits in my pr branch
@_RustyRooster
I just now read about the differences.
Using git rebase instead of git pull can result in a cleaner history by incorporating changes without creating any additional merge commits.
super helpful when working as a team. thanks for sharing !!