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

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay