Essential Git Commands

farhatsharifh

Farhat Sharif

Posted on September 6, 2024

Essential Git Commands

Once you have set up your git repository (as described in the previous post), here come the next steps. When you start using git, these are the steps you will find yourself doing frequently. Whenever you make changes to your project, these commands will help you manage the changes efficiently.

1. Check Your Files' Status:

Command: git status
Description: This command shows the current status of your repository. It lets you know which files have been modified, which are new, which are staged for commit and which aren’t.

2. Stage Your Changes for Commit

Command: git add <file_name> or git add .
Description: After editing or adding files, use the command to add the changes to the staging area. You can stage individual files by name or all changes at once by using git add . command.

3. Commit Your Changes

Command: git commit -m "commit message"
Description: Once the changes are staged, use git commit command to store them and include a descriptive message that explains the changes you made. Commit is like a snapshot of your repository's current state used to maintain history and track changes.

4. Push Your Changes to the Remote Repository

Command: git push
Description: After committing your changes, push them to your remote repository.
(You need to set the upstream branch once, which we have done in previous post. After that using git push will be enough.)

These simple commands will help streamline your workflow with git.

💖 💪 🙅 🚩
farhatsharifh
Farhat Sharif

Posted on September 6, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

Essential Git Commands
beginners Essential Git Commands

September 6, 2024