User Tools

Site Tools


git_cheatsheet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

git_cheatsheet [2025/01/12 01:23] – created smickstergit_cheatsheet [2025/01/12 01:25] (current) smickster
Line 1: Line 1:
 ====== Git Cheatsheet ====== ====== Git Cheatsheet ======
  
-0. git init: Initializes a new Git repository. +  * git init: Initializes a new Git repository. 
-1. git clone [url]: Creates a local copy of a remote repository. +  git clone [url]: Creates a local copy of a remote repository. 
-2. git status: Displays the state of the working directory and staging area. +  git status: Displays the state of the working directory and staging area. 
-3. git add [file]: Adds a file to the staging area. +  git add [file]: Adds a file to the staging area. 
-4. git reset [file]: Unstages a file while retaining the changes. +  git reset [file]: Unstages a file while retaining the changes. 
-5. git diff --staged: Shows differences between the staging area and the last commit. +  git diff --staged: Shows differences between the staging area and the last commit. 
-6. git commit -m "[message]": Records staged changes with a descriptive message. +  git commit -m "[message]": Records staged changes with a descriptive message. 
-7. git branch: Lists all local branches. +  git branch: Lists all local branches. 
-8. git checkout -b [name]: Creates and switches to a new branch. +  git checkout -b [name]: Creates and switches to a new branch. 
-9. git log: Displays commit history. +  git log: Displays commit history. 
-10. git remote add [ref] [url]: Adds a new remote repository. +  git remote add [ref] [url]: Adds a new remote repository. 
-11. git push [alias] [branch]: Uploads local branch commits to a remote repository. +  git push [alias] [branch]: Uploads local branch commits to a remote repository. 
-12. git pull: Fetches and merges changes from the remote to the local repository. +  git pull: Fetches and merges changes from the remote to the local repository. 
-13. git stash: Temporarily stores modified tracked files. +  git stash: Temporarily stores modified tracked files. 
-14. git stash pop: Restores the most recently stashed files. +  git stash pop: Restores the most recently stashed files. 
-15. git stash drop: Discards the most recently stashed changeset. +  git stash drop: Discards the most recently stashed changeset. 
-16. git rebase [branch]: Reapplies commits on top of another base tip. +  git rebase [branch]: Reapplies commits on top of another base tip. 
-17. git rebase -i HEAD~<n>: Starts an interactive rebase for the last n commits. +  git rebase -i HEAD~<n>: Starts an interactive rebase for the last n commits. 
-18. git reset --hard [commit]: Resets the working directory to a specified commit. +  git reset --hard [commit]: Resets the working directory to a specified commit. 
-19. git log branchB..branchA: Shows commits on branchA that are not on branchB. +  git log branchB..branchA: Shows commits on branchA that are not on branchB. 
-20. git diff branchB...branchA: Displays differences between two branches. +  git diff branchB...branchA: Displays differences between two branches. 
-21. git show [SHA]: Shows the changes in a specific commit. +  git show [SHA]: Shows the changes in a specific commit. 
-22. git config --global core.excludesfile [file]: Sets up a global file for ignoring files.+  git config --global core.excludesfile [file]: Sets up a global file for ignoring files.
  
 Use oh-my-zsh and you only have to type 2-3 letters for each command Use oh-my-zsh and you only have to type 2-3 letters for each command
git_cheatsheet.1736645033.txt.gz · Last modified: by smickster

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki