Skip to content

Instantly share code, notes, and snippets.

@bitwisebro
Last active September 7, 2023 09:52
Show Gist options
  • Select an option

  • Save bitwisebro/848f724be7e544c00053fa35aa16a2cc to your computer and use it in GitHub Desktop.

Select an option

Save bitwisebro/848f724be7e544c00053fa35aa16a2cc to your computer and use it in GitHub Desktop.
Git Commands for Normies

Author: Gaurav Jani

  1. Clone the Repo:

    • git clone <repo_url>
  2. Switch to Branch you want:

    • git checkout branch_name
  3. Stage modified files:

    • git add <filename1, filename2>
    • to add all files=> git add .
  4. Commit the staged files:

    • git commit -m "commit msg"
  5. check branch: -git branch -git branch -a

  6. push the code to remote branch:

    • git push
    • git push origin remote_branch_name
  7. pull the changes from a branch

    • git pull origin branch_name
  8. Check Remote Git URL:

    • git remote -v
  9. Set Remote Git:

    • git remote add origin
  10. Change Remote git URL:

    • git remote set-url origin
  11. View Changed files:

    • git status
  12. View how much changes in files:

    • git diff --stats
  13. View git Logs:

    • git log
  14. Rollback fro previous commit:

    • git checkout <commit_hash>
  15. Force push:

    • git push -f origin
  16. Stash the changes: -git stash

  17. Re-Apply the Changes: -git stash pop

  18. See What's in Stash:

    • git stash list
  19. Clear the Stash

    • git stash clear
  20. Drop a particular stash

    • git stash drop stash@{index} # Index will be shown after getting stash list
  21. Show Ref

    • git show-ref
  22. List all Tags

    • git tag
  23. Create lightweight tag

    • git tag tagname
  24. Create annotated tag

    • git tag -a tagname -m "msg"
  25. Push a tag to Remote

    • git push origin tagname
  26. Pull all local tags to Remote

    • git push origin --tags
  27. Delete a tag

    • git tag -d tagname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment