Git- Basic Commands
April 3rd 2020 726
In the previous tutorial we have install git on our system. In this tutorial we will see some basic command in Git. we will use these commands in the next tutorial, here our aim is to know what are the commands in git and what are their usage.
Basic Git Commands:
1) git init
Utility: To initialize a git repository for a new or existing project.
How to: git init in the root of your project directory.
2) git clone
Utility: To copy a git repository from a remote source, it also sets the remote to original source so that you can pull again.
How to: git clone <:git url:>
git clone https://github.com/altaf99/Friends-The-Social-Network.git
3) git status
Utility: To check the status of files you’ve changed in your working directory, i.e, what all has changed since your last commit.
How to: git status in your working directory. lists out all the files that have been changed.
4) git add
Utility: adds changes to stage/index in your working directory.
git add .
5) git commit
Utility: To save changes to the local repository safely. Commit takes a snapshot of the project and treats it as a version.
git commit -m ”sweet little commit message”
6) git push
Utility: It is used to transfer or push the commit, which is made on a local branch in your computer to a remote repository
How to: git push <:remote:> <:branch:>
git push origin master
7) git pull
Utility: It is used to fetch and download content from a remote repository and immediately update the local repository to match that content.
How to: git pull <:remote:> <:branch:>
git pull origin master
8) git --version
Utility: To check the version if the git is installed
9) git remote
Utility: To check what remote/source you have or add a new remote.
How to: git remote to check and list. And git remote add <:remote_url:> to add a remote.
git remote add https://github.com/altaf99/Friends-The-Social-Network.git
Congratulations!! We have learned basic commands of Git and now we are ready to use them and see Git in action, in our next tutorial.