Git Cheat Sheet

In this tutorial, How to use the git command every day. Git cheat sheet I use every day.

What does Git mean?

Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Quote from Wikipedia.

Git Cheat Sheet example

Check my git configure

git config -l

Setup my Git username and Email Id

git config --global user.name "HuuPV"
git config --global user.email "HuuPV@devopsroles.com"

Username and EmailID assigned to commit from local computer.

Initialize an empty Git repo

git init

Add a file to the staging area in Git

git add file_name

Add all files in your project to the staging area in Git

git add .

Commit changes for the files in a local repo.

git commit
git commit -m "first commit"

shows the commit history for the current repository

git log

Show if a file is in the staging area, but not committed

git status
git status devopsroles.com

Remove tracked files from the current working tree

git rm filename

Rename files


git mv oldfile newfile

Create a new branch


git branch branch_name

Switch to a newly created branch


git checkout branch_name

Create a new branch and switch it immediately

git checkout -b branch_name

List branches


git branch
Git Cheat Sheet

Merge two branches

git merge branch_name

Add a remote repository to your local repository

git add remote https://repo_url_here

Git clone

git clone

download updates from a remote repository.

git pull

After committing your changes, the next you send changes to the remote server.

git push
#or force push
git push -f

Conclusion

You have used Git Cheat Sheet every day. I hope will this your helpful. Thank you for reading the DevopsRoles page!

,

About HuuPV

My name is Huu. I love technology and especially Devops Skill such as Docker, vagrant, git so forth. I likes open-sources. so I created DevopsRoles.com site to share the knowledge that I have learned. My Job: IT system administrator. Hobbies: summoners war game, gossip.
View all posts by HuuPV →

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.