Skip to content

naxchin/git_cheatsheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 

Repository files navigation

git_cheatsheet

My own quick reference for basic Git commands

  • delete a branch : git branch -d

  • rename branch : git branch branchname log_number

  • remove something from your repo git rm --cached .vscode

  • rewriting the most recent commit message git commit --amend

Using Git when working with a team

Different kind of branches :

  • main branch (protected)
  • feature branches (one branch per feature)
  • bug fixes branches
  1. To create a new branch git checkout -b name-you-want-for-branch

  2. Check every day whether there is a change on the main branch

  • switch from your branch to main git checkout main
  • get the latest version of the remote main with
    • git pull origin main OR
    • git pull --rebase origin main(if merge conflict during the rebase : resolve the file's conflicts and continue on the command line git add . && git rebase --continue)
  • switch back to the branch you are working on git checkout your-branch-name
  • merge the changes from main to your branch git merge main
  1. Push your local branch to Github
  • git add .
  • git status
  • git commit -m "your-commit-message"
  • git push -u origin your-branch-name
  1. Merge your branch to the main branch
  • from your branch :
    • add, commit and push your local branch
    • bring changes from main to your local branch git pull origin main (make sure your in your branch)
  • create a pull request
  • if conflict :
    • git pull origin main (make sure your in your branch)
    • resolve conflict
    • add, commit and push your local branch
  • if pull request approved :
    • go to main branch and get all the changes from the pull request : git pull origin main (make sure your in the main branch)
    • delete your branch git branch -D your-branch-name
  1. Other
  • to view all existing branches git branch -a
  • to delete a branch git branch -d branch-name
  • to check the destination of where your code is going to be pushed git remote -v

Check also

Illustrated workflow - without pull request alt text

About

My own quick reference for basic Git commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published