Saturday 13 August 2016

Using Git

Everyone must have an idea of Git. If not, you are not following my blogs. Find it here: "Why Git?(advertisement may come; skip if you want to)

Git is used to push repository from local to remote, clone and pull repository from remote to local. Lets get to the steps to do that directly. We will use terminal to write commands:

From Local to Remote

  1. Go to the folder where your file is stored using 'cd' command. Suppose you are at home and the file is stored in Downloads. Go to Downloads by writing the command 'cd Downloads'. By the way, home can be reached by just typing 'cd' in the terminal. After reaching the Downloads, you need to initialize git here. Git can be initialized by writing 'git init' command. This should create a .git folder in Downloads.
  2. Next step would be to add your file to the Git. Adding can be explained as picking a particular file from a list of files in that folder. This can be done with the command 'git add file_na, me.txt'.
  3. git commit -m "any message". This command will commit the file to your git. Your push will come the message you write under the double inverted commas.
  4. git remote add origin ...... This command will link your local to the remote. The address of the remote is written after origin. Origin is just name of your local repository. You can give any name.
  5. Now this command will push your file to the remote: "git push origin master".
From Remote to Local


  1. git clone ...... write this command in your terminal and repository will be saved into local.  The address of the remote is written after clone. Folder with the same name as the repository will be created in the directory where where you are currently.

Well this was all about pushing and cloning from local to remote and vice-versa. Any time you can run the command git status to check which files are added, which files are committed and which files are needed to be commit. There are many more thing which needs to be discussed about Git, but will leave it for the next time. I will also discuss about SSH.

Keep Learning, Keep Sharing..~~!!
Ta-Ta
Click Here for my Blog (advertisement may come; skip if you want to)


No comments:

Post a Comment