salcode / salcode-git

My Git configuration.
MIT License
3 stars 1 forks source link

Add alias to check if branch is up to date with another branch #26

Closed salcode closed 7 months ago

salcode commented 8 months ago

I often want to know if my current branch (e.g. feat/a) is up to date with another branch (e.g. main).

In this case, I typically run something like

$ git switch feat/a
$ git pull feat/a
$ git switch main
$ git pull main
$ git switch feat/a
$ git log --oneline --graph

and I look to see if main appears in the log history of feat/a.

We've already introduced git can-ff-merge, which could be used to determine if feat/a into main is a fast-forward merge but it would be nice to have a separate alias to check if up to date.

Perhaps something like git is-up-to-date-with main or something similar.

salcode commented 8 months ago

I'm not sure I'm a fan of including git pull in this alias.

Perhaps we should eliminate git pull with the idea that updating branches should be handled by the user.

A user could eliminate the need for the second pull by running git fetch --all first and then use origin/main instead of just main,

salcode commented 8 months ago

Instead of git is-up-to-date-with should we change the name to something like git has-diverged-from (which would give us the opposite answer)?