Thursday, April 21, 2016

Starting with git repo

Hey,

I need to create a repository and make a clone of it. Creating a repo in git id easy and you can do it via github UI. I guess you are familiar with github and you may have played with some git repos.

This post will summarize steps of creating a clone in local machine and make a commit using that.
Lets begin...

Preconditions:

  • Have account in github.
  • Installed git in your local machine
  • Have access to repo which is going to clone (Most probably it may be a public or your own one)

Steps to follow:

You have to use following commands:

         git clone <link>
                Ex: git clone https://github.com/Dilshani/BlogStuff.git
     
         git config --global user.email "you@example.com"

         git config --global user.name "Your Name"
 
         git remote add <name for repo> <url of repo>

         git add .         -->  (This will add all new files to commit)

         git commit -m "message"

         git push origin master

Then newly added stuff will be committed to repo. (If you own the repo, you don't need to make a  commit request by github UI. Otherwise, you have to go and make a pull request)

When you are committing files again, you can proceed with "git add" command onwards.

Note: You can add files separately or add all at once.

git add <file name>  ----  > Add file by file

git add .   -----> Add all files at once

Now you know how to add commits to git hub repo. Well Done :)



No comments:

Post a Comment