Basic Git Commands
Command Description
git init Initialize a new Git repository in the current directory.
git clone <repository> Clone a repository into a new directory.
git add <file> Add changes in a file to the staging area.
git add. or git add --all Add all changes to the staging area.
git commit -m message Commit changes in the staging area with a message.
git status Show the status of changes as untracked, modified, or staged.
git log Display the commit history.
git branch List all local branches, with the current branch highlighted.
git branch <branch_name> Create a new branch.
git checkout <branch_name> Switch to a different branch.
git merge <branch_name> Merge changes from another branch into the current branch.
git pull Fetch changes from a remote repository and merge them into the current branch.
git push Push local changes to a remote repository.
git remote -v Show a list of remote repositories and their URLs.
git fetch Fetch changes from a remote repository.
git reset <file> Unstage changes for a file.
git rm <file> Remove a file from the working directory and the repository.
git diff Show the differences between the working directory and the staging area.
git diff <commit1> <commit2> Show the differences between two commits.
git tag <tag_name> Create a lightweight tag for the current commit.
git remote add <name> <url> Add a remote repository.
git pull origin <branch> Pull changes from a specific branch of the remote repository.
git push origin <branch> Push changes to a specific branch of the remote repository.