Mar 26, 2015

Git and Github

Git/Github is a helpful documentation technique when u are changing a file frequently, mostly in the programming language code and you may need to toggle and compare between the various edits. Also, it really helps when multiple users are working on the same file and we want to trace the update by various users.

First thing first,

One needs to get a account in www.github.com. You need to get a username and password for a registered email id. After having the github account we need to install git in our computer.

For linux, we install it as:

sudo apt-get update
sudo apt-get install git

Then we need to setup Git:

git config --global user.name "our_username"
git config --global user.email  "our_emailid"

we can see our configuration later as

git config --list

Having set up the git, we need to have a folder where we will work or say assign a git work-space folder. For that:
First create a folder and change directory to that folder
$ mkdir ~/git/userfolder_name       
$ cd ~/git/userfolder_name

We may create a sample file
~/git/userfolder_name $ touch file_name

Next convert it to the workspace environment
~/git/userfolder_name $ git init

To add the files in the folder to the git repository, we use
~/git/userfolder_name $ git add .

Whenever we make a change to our repository we need to make a commit message
~/git/userfolder_name $git commit -m "My_commit" -a
~/git/userfolder_name $git commit -m "My_commit" file_name


Upto now, we have worked with out local server.
~/git/userfolder_name $git remote add origin ssh://git@github.com:user_name/repository_name.git
~/git/userfolder_name $git remote -v

No comments:

Post a Comment