GitHub

Git/GitHub


Git Install 
We can install the Git command line tool using the command below:
$ sudo apt-get install git 

$ git --version
git version 1.9.1
Creating a git repository
$ git init project1
Initialized empty Git repository in /home/k/GitTraining/project1/.git/
Note that we do not have any server, and there is no background daemon. We just used local file system to create the project1 directory and the nested .git directory.
$  cd project1
$ ls
$ ls -al
total 12
drwxrwxr-x 3 k k 4096 Jun  3 09:52 .
drwxrwxr-x 3 k k 4096 Jun  3 09:52 ..
drwxrwxr-x 7 k k 4096 Jun  3 09:52 .git
$ tree .git
tree_git.png 
Unlike other source control system such as CVS, there is only one .git folder at the top level. Only one.git per repository!
Also, note that we do not have any file in the repository yet:
$ git status
On branch master

Initial commit

nothing to commit (create/copy files and use "git add" to track)
Now we make our first ifle: first.txt.
Let's see how the git think of the file:
$ git status
On branch master

Initial commit

Untracked files:
  (use "git add ..." to include in what will be committed)

 first.txt

nothing added to commit but untracked files present (use "git add" to track)



Adding a file to a git

$ git add first.txt
The git add is merely telling the git our intention of adding for the next transaction. It's not adding the file to a repo yet. It just signals our participation. We do not have a permanent recode of the file yet.
We can see the changes to be committed using git status:
$ git status
On branch master

Initial commit

Changes to be committed:
  (use "git rm --cached ..." to unstage)

 new file:   first.txt
Now we can commit to the master:
$ git commit -m "My first commit"
[master (root-commit) b025f57] My first commit
 1 file changed, 50 insertions(+)
 create mode 100644 first.txt
Here, the b025f57 is a global unique identifier. The 644 indicates the user can read and write and others and group just can read the file.
Now we have permanent record of the file and we can see our current directory is clean:
$ git status
On branch master
nothing to commit, working directory clean