logoalt Hacker News

MathiasPiusyesterday at 4:15 PM4 repliesview on HN

You can pull another branch without switching first:

  git switch my-test-branch
  ...
  git pull origin main:main
  git rebase main

Replies

hiccuphippoyesterday at 5:16 PM

You can also rebase directly on the remote branch

    git fetch
    git rebase origin/main
WickyNilliamsyesterday at 4:30 PM

Nice. That'll make things a bit smoother. Changing branches often trips me up when I would later `git switch -`.

mrocheyesterday at 5:09 PM

Likewise with the other way around, just switch pull with push.

huntervangyesterday at 4:46 PM

I have always done `git pull origin main -r`