git --help
: Displays options for git commands.git -h
: Provides a shorter summary for options and help.git init
: Initializes a git repository in the current directory.git add <file1> <file2>
: Adds specified files to the staging area.git add .
: Adds all files to the staging area.git status
: Checks untracked, modified files and files in the staging area.git commit -m "<commit description>"
: Commits changes in the staging area with a message.git commit -a -m "<description>"
: Adds all changes to staging and commits in one step.rm <filename>
: Removes a file from the directory but not from the staging area.git add <deleted file from directory>
: Removes the deleted file from the staging area.git ls-files
: Lists the files in git's staging area.git rm <filename>
: Removes the file from both the working directory and the staging area.git mv <old file name> <new file name>
: Renames a file.echo <directory/> >> .gitignore
: Adds a directory or file to the .gitignore file to ignore changes.git status -s
: Provides a shorter summary; the left column indicates the staging area and the right column indicates the working directory.git difftool
: Launches the diff tool.git reset <file name>
: Unstages a file.git reset HEAD~1
: Undoes the last commit.git reset <hash of a commit>
: Goes back to a certain commit.git log
: Prints the commit history.git log --oneline
: Provides a shorter description of commits.git restore --staged <filename>
: Removes a file from the staging area.git push -u origin master
: Pushes the changes to the master branch on the remote repository.git pull
: Fetches and merges changes from the remote repository.git branch
: Displays branches.git checkout <name of the branch>
: Switches between branches.git checkout -b <name of the branch>
: Creates a new branch.git branch -d <name of the branch>
: Deletes a branch.git merge <branch to merge to>
: Merges a specified branch into the current branch.git config --global user.name "<user name>"
: Sets the username at a global level.git config --global user.email <email>
: Sets the email at the global level.git config --global core.editor "code --wait"
: Sets the default editor to VS Code.git config --global -e
: Opens the global settings in the default editor.git config --global core.autocrlf true
: Sets the end of line to automatic add CRLF (for Windows).git config --global core.autocrlf input
: Manages end of line from other users (for Mac/Linux).git config --global difftool.code.cmd "code --wait --diff $LOCAL $REMOTE"
: Sets VS Code as the diff tool.git config --global diff.tool code
: Sets the diff tool to VS Code.ssh-keygen -t rsa -b 4096 -C "<email.com>"
: Generates an SSH key via RSA encryption.cat testkey.pub
: Displays the public key to copy.git remote add origin <ssh link>
: Links the local repository to the GitHub repository.