Skip to content

Instantly share code, notes, and snippets.

@jeroensmink98
Last active April 13, 2022 07:47
Show Gist options
  • Save jeroensmink98/9a3d7fa4a630d3d2fcd8c2045c6428fd to your computer and use it in GitHub Desktop.
Save jeroensmink98/9a3d7fa4a630d3d2fcd8c2045c6428fd to your computer and use it in GitHub Desktop.
Some simple Git commands

Basic Git Commands

Some simple Git commands

Checkout a new branch

  • git pull
  • git checkout -b [name_of_your_new_branch]
  • git push origin [name_of_your_new_branch]

Commiting

  • git commit -am "commit message"

Git Rebasing

  • Pull the latest staging/master branch to your machine
  • Switch to your own branch
  • Run git rebase staging
  • Next force push the changes of your branch git push -f

Merging two branches into one

It is a good practise to first create a backup of your own branch

  • Run git fetch to get the latest changes
  • Next git checkout -b <branch-name> to create a new branch.
  • Run git cherry-pick <first-commit-hash>^..<second-commit-hash> To retrieve changes of other branch
  • At last run git push -f to forcefully push the changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment