DEV Community

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

Posted on • Updated 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

Top comments (0)