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 –global user.name “[name]” – It will set author name for your commits.
git config –global user.email “[email address]” – It will set email address which can be used with your commits.
git init [repository name] – It will start a new repository.
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 [url] - It let you to obtain a repository from an existing URL.
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– 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.
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 <options>
The git fetch command gets the latest resources from the specified origin and it doesn’t merge the changes.
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 [file] – It will deletes the file from your working directory and stages the deletion.
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 – It let you to list out the version history.
git branch– It help you to list out the all local branches from current repository.
git checkout [branch name]– You can switch from one branch to another branch.
git remote add [variable name] [Remote Server Link] – Connect your local repository to the remote server.
git merge [branch name]-It merges the mentioned branch’s history into the current branch.
git tag [commitID]– You can use this command to provide the tag to a specific commit.
git push [variable name] master – It is used to push changes to remote repositories.
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.