Set your name for all commits:
git config --global user.name "[name]"Set your email for all commits:
git config --global user.email "[email]"Set the default branch name to 'main':
git config --global init.defaultBranch mainInitialize a new local Git repository:
git initClone an existing repository from a URL to your local machine:
git clone [url]Show the status of changes as untracked, modified, or staged:
git statusAdd a specific file to the staging area:
git add [file]Add all new and modified files to the staging area:
git add .Commit your staged changes with a descriptive message:
git commit -m "[message]"View the commit history:
git logList all local branches:
git branchCreate a new branch:
git branch [branch-name]Switch to a different branch:
git checkout [branch-name]Create a new branch and switch to it immediately:
git checkout -b [branch-name]Merge the specified branch’s history into the current one:
git merge [branch]Delete a local branch:
git branch -d [branch-name]List all remote repositories:
git remote -vAdd a new remote repository:
git remote add origin [url]Download all history from a remote repository without merging:
git fetch [remote]Fetch and merge changes from the current branch's remote counterpart:
git pullPush a specific branch to the 'origin' remote:
git push origin [branch]Temporarily save modified, tracked files in order to switch branches:
git stashApply the most recent stash and remove it from the list:
git stash popList all stashed changesets:
git stash listDiscard the most recent stash:
git stash dropUnstage a file, but preserve its contents in the working directory:
git reset [file]Discard all local changes in a specific file:
git checkout -- [file]Create a new commit that undoes the changes from a specified commit:
git revert [commit-hash]