Git Commands
π git init β Initialize a new Git repository
π₯ git clone <repo> β Clone a repository
π git status β Check the status of your repository
β git add <file> β Add a file to the staging area
π git commit -m "message" β Commit changes with a message
π git push β Push changes to a remote repository
β¬οΈ git pull β Fetch and merge changes from a remote repository
Branching
π git branch β List all branches
π± git branch <name> β Create a new branch
π git checkout <branch> β Switch to a branch
π git merge <branch> β Merge a branch into the current branch
β‘οΈ git rebase <branch> β Apply commits on top of another branch
Undo & Fix Mistakes
βͺ git reset --soft HEAD~1 β Undo the last commit but keep changes
β git reset --hard HEAD~1 β Undo the last commit and discard changes
π git revert <commit> β Create a new commit that undoes a specific commit
Logs & History
π git log β Show commit history
π git log --oneline --graph --all β View commit history in a simple graph
Stashing
π₯ git stash β Save changes without committing
π git stash pop β Apply stashed changes and remove them from stash
Remote & Collaboration
π git remote -v β View remote repositories
π‘ git fetch β Fetch changes without merging
π΅οΈ git diff β Compare changes
Donβt forget to react β€οΈ if youβd like to see more content like this!
Post #1123
1.3K
- π 4