This guide provides a list of important Git commands that you might need to use.
These commands are typically used when you're setting up your Git repository for the first time.
-
git init
- This command creates an empty Git repository locally.
-
git remote add origin "REMOTE URL"
- This command links your local repository to the remote one.
-
git status
- This command shows the status of your local repository.
-
git add -A
- This command stages all changes for commit. You can check if everything is staged correctly by running
git status
and ensuring everything is green.
- This command stages all changes for commit. You can check if everything is staged correctly by running
Before making your first commit, you need to set up your Git user name and email:
-
git config --global user.name "YOUR NAME"
-
git config --global user.email "YOUR EMAIL"
-
git commit -m "YOUR COMMIT MESSAGE/COMMENT"
- This command commits your changes with a message.
-
git push -u origin master
- This command pushes all changes from your local repository to the remote one. You'll be prompted to enter your remote username and password.
If you've made some changes on the remote repository and want to sync them with your local one, use this command:
git pull origin master
These commands are used for regular work with your Git repository:
-
git status
- Check the status of your local repository.
-
git add
- Stage changes for commit.
-
git commit
- Commit your changes.