Common Git Commands
You can find a list of all Git commands on the official Git documentation site. Listed below are some of the most common Git commands you will use on a daily basis.
git init
Initializes a new Git repository in your project folder.
git clone [url]
Copies an existing Git repository from a remote server (like GitHub) to your local machine.
git status
Shows you the current state of your working directory—whether files have been changed, added, or are ready to be committed.
git add [file]
Stages a file (or files) for the next commit. It’s like saying, “Hey Git, include these changes in the next snapshot.”
git commit -m "message"
Saves the staged changes with a descriptive message explaining what you did.
git push
Uploads your local commits to a remote repository (like GitHub), so others can see and collaborate on your work.
git pull
Fetches the latest changes from a remote repository and merges them into your local branch.
git branch
Lists all the branches in your repository (branches are like parallel versions of your project).
git checkout [branch]
Switches to a different branch to work on a different version of your project.
git merge [branch]
Combines the changes from one branch into another, usually to bring new features into the main project.
git fetch
Fetches the latest changes from a remote repository without merging them.