Tutorials

Git Commands Tutorials For Beginners

Insight: Git Commands Tutorials For Beginners

We hope that at this point of reading this article you are aware of what actually Git is. In this post, we are going to talk about few Git commands tutorials.

Git Commands Tutorials For Beginners

git config

Syntax

git config –global user.name “[name]”  – It will set author name for your commits.

Syntax

git config –global user.email “[email address]”  – It will set email address which can be used with your commits.

git init

Command Syntax

git init [repository name] – It will start a new repository.

Git Commands Tutorials For Beginners

git add

Command Syntax

git add [file] – It will add a file to the staging area. You can use the git commit command to make them permanent on historical snapshots.

git add * – It will adds one or more file to the staging area.

git clone

Command Syntax

git clone [url] - It let you to obtain a repository from an existing URL.

git commit

Command Syntax

git commit -m “[ Type in the commit message]” – This command will snapshots the file permanently or will records the file permanently in version history.

git diff

Command Syntax

git diff– You can use this command to check the file differences which are not yet staged. For example: Let’s suppose we are working on omgfoss.txt file. We are editing the few lines of the file. We removed the few lines and added a new line in the file. Now, The diff command will show the differences between the committed version and the local version in the staging area. It’s like difference between the earlier version and the updated or edited version of the file.

READ THIS ALSO  Collection Of Best IDEs For Linux In 2018 : Linux Programming

git diff –staged– It will show the differences between the files in the staging area and the latest version.

git diff [first branch] [second branch] – It will show the differences between the two branches as mentioned in the command.

git fetch

git fetch <options>
The git fetch command gets the latest resources from the specified origin and it doesn’t merge the changes.

git reset

Syntax Command

git reset [file]  – If you want to save the content of the files but want to reset it then this command will help you to unstage the added file, but it preserves the file contents.

git rm

Syntax Command

git rm [file] – It will deletes the file from your working directory and stages the deletion.

git status

Syntax Command

git status – It list out the all files that have to be committed or it displays the difference between current files and the HEAD commit.

git log

Syntax Command

git log – It let you to list out the version history.

git branch

git branch– It help you to list out the all local branches from current repository.

git checkout

git checkout [branch name]– You can switch from one branch to another branch.

git remote

git remote add [variable name] [Remote Server Link] – Connect your local repository to the remote server.

git merge

git merge [branch name]-It merges the mentioned branch’s history into the current branch.

git tag

git tag [commitID]– You can use this command to provide the tag to a specific commit.

READ THIS ALSO  [How to] Install FlatPak on Ubuntu

git push

git push [variable name] master – It is used to push changes to remote repositories.

git show

git show [commit] – Displays the metadata and content changes of the mentioned commit.

This much for now. Let us know if there is any error in this post.



Subscribe To Our Newsletter.

Join our mailing list to receive the latest linux tutorials, tips & tricks, freebies,news and updates from our team.

You have Successfully Subscribed!