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

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay