DEV Community

Cover image for The Git Commands I Use Every Day
Ifeanyi Chima
Ifeanyi Chima

Posted on • Edited on

The Git Commands I Use Every Day

Git will keep track of changes you make to your project.

BMC

1. Initialize a Git repo

This will introduce Git into your project. Create a local repo.

git init
Enter fullscreen mode Exit fullscreen mode

2. Add Remote

Add a remote GitHub repository to your project.

git remote add origin git@github.com:XxxxxxX/welcomeToBrixton.git
Enter fullscreen mode Exit fullscreen mode

3. Add a file to staging

move file(s) from the working directory to a staging area. The flag . will add all files.

git add .
Enter fullscreen mode Exit fullscreen mode

4. Commit

commit all staged files to Git. -m is a flag used to attach a commit message.

git commit -m "commit message"
Enter fullscreen mode Exit fullscreen mode

5. Push to GitHub

This will send your project which is currently on your local machine to a remote GitHub repository. -u is a flag you can use to set upstream

git push origin <branch>
Enter fullscreen mode Exit fullscreen mode

6. Log

List all the commit(s) with a hash.

git log
Enter fullscreen mode Exit fullscreen mode

To go to any of the commits, copy the first few characters of the commit hash and then

git checkout <commit_id>
Enter fullscreen mode Exit fullscreen mode

7. Status

List new or modified files not yet committed

git status
Enter fullscreen mode Exit fullscreen mode

Thank you

Buy Me A Coffee

Follow me on linkedin, github and twitter

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay