Git

less than 1 minute read

Migrate my notes on Git from Google Keep to here

PR steps

  1. create fork in the console
  2. git pull and git checkout -b new_branch
  3. modify/add/commit/push origin
    git push --set-upstream origin new_branch
  4. create pull request

Sync your fork

  1. git remote add upstream git@xxxxx

  2. git fetch upstream
  3. git checkout main and git merge upstream/main

push fetched to fork

  1. git push # to update
  2. more modify/push
  3. git brach -d new_branch
  4. git push origin -d new_branch ( delete the one in the console)

Merge vs Rebase

More details at this link

git merge mainis a non-destructive operation. The existing branches are not changed in any way, and feature branch will have an extraneous merge commit every time you need to incorporate upstream changes.
Alt text

git rebase main moves the entire feature branch to begin on the tip of the main branch, effectively incorporating all of the new commits in main. It re-writes the project history.
Alt text

The golden rule of rebasing

Never use it on public branch. It will force main to get all commit from you, while others don’t need. Alt text

Tags:

Categories:

Updated: