GIT: Git Commands Cheat Sheet

By PNC No comments

Commands Cheat Sheet

  1. Creating a new branch.
    git checkout -b YourBranchName
  2. Going to an existing branch.
    git checkout YourBranchName
  3. Deleting a local branch.
    git branch --delete YourBranchName
  4. Deleting a remote branch.
    git push origin --delete YourBranchName
  5. To fetch the latest updates from a branch.
    git pull origin YourBranch
  6. To add the latest changes to branch.
    git add .
    git commit -m "your commit description"
    git push origin YourBranchName
  7. Cloning a repository.
    git clone RepositoryLink
  8. To add a remote repository.
    git remote add origin RepositoryLink
  9. To update a remote repository link.
    git remote set-url origin RepositoryLink
  10. To list all local branches.
    git branch --list
  11. To know what branch you’re currently at.
    git branch
  12. To switch branch.
    git checkout YourBranchName
  13. To merge a branch to another branch.
    In this example, we will be merging BranchOne to BranchTwo.  BranchTwo is your working branch.
    git checkout BranchTwo
    Once you’re in your working branch, call the command:
    git merge BranchOne