In git you would need to initialize a Repository first which would be empty at the start point.
We are going to create a test directory and initialize the directory as our git Repository
~ $ mkdir test
~ $ cd test/
~/test $ git init
Initialized empty Git repository in /root/test/.git/
Initializing a directory creates a subdirectory of .git which includes files used by git to track the changes
~/test $ cd .git/
~/test/.git $ ll
total 32
drwxr-xr-x. 2 root root 4096 May 1 20:11 branches
-rw-r--r--. 1 root root 92 May 1 20:11 config
-rw-r--r--. 1 root root 73 May 1 20:11 description
-rw-r--r--. 1 root root 23 May 1 20:11 HEAD
drwxr-xr-x. 2 root root 4096 May 1 20:11 hooks
drwxr-xr-x. 2 root root 4096 May 1 20:11 info
drwxr-xr-x. 4 root root 4096 May 1 20:11 objects
drwxr-xr-x. 4 root root 4096 May 1 20:11 refs
If we are going to check in the test directory , the git will show there is nothing to commit
~/test $ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
So we are going to create an test.txt file
~/test $ echo "This is just my test file" > test.txt
Now if we are going to check the git status , it will treat this as untracked since its not been added to git yet
~/test $ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# test.txt
nothing added to commit but untracked files present (use "git add" to track)
So we are going to add this file to the git
~/test $ git add test.txt
~/test $ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: test.txt
#
Next we need to commit the changes, commiting the changes would inturn open a comment section where you need to enter the descriptive comment about the changes so everyone is aware about what changes have you made at that instant
~/test $ git commit
[master (root-commit) ae1620a] This is my Test text file
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 test.txt
We are going to create a test directory and initialize the directory as our git Repository
~ $ mkdir test
~ $ cd test/
~/test $ git init
Initialized empty Git repository in /root/test/.git/
Initializing a directory creates a subdirectory of .git which includes files used by git to track the changes
~/test $ cd .git/
~/test/.git $ ll
total 32
drwxr-xr-x. 2 root root 4096 May 1 20:11 branches
-rw-r--r--. 1 root root 92 May 1 20:11 config
-rw-r--r--. 1 root root 73 May 1 20:11 description
-rw-r--r--. 1 root root 23 May 1 20:11 HEAD
drwxr-xr-x. 2 root root 4096 May 1 20:11 hooks
drwxr-xr-x. 2 root root 4096 May 1 20:11 info
drwxr-xr-x. 4 root root 4096 May 1 20:11 objects
drwxr-xr-x. 4 root root 4096 May 1 20:11 refs
If we are going to check in the test directory , the git will show there is nothing to commit
~/test $ git status
# On branch master
#
# Initial commit
#
nothing to commit (create/copy files and use "git add" to track)
So we are going to create an test.txt file
~/test $ echo "This is just my test file" > test.txt
Now if we are going to check the git status , it will treat this as untracked since its not been added to git yet
~/test $ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# test.txt
nothing added to commit but untracked files present (use "git add" to track)
So we are going to add this file to the git
~/test $ git add test.txt
~/test $ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: test.txt
#
Next we need to commit the changes, commiting the changes would inturn open a comment section where you need to enter the descriptive comment about the changes so everyone is aware about what changes have you made at that instant
~/test $ git commit
[master (root-commit) ae1620a] This is my Test text file
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 test.txt
You might add large number of files all together to the git and commit to track the changes. for this we are going to create another directory named dir2 and copy all the files starting with h under /etc and add them to the git and commit the changes
~/test $ cd ..
~ $ mkdir dir2
~ $ cd dir2
~/dir2 $ cp /etc/h* .
cp: omitting directory `/etc/hal'
cp: omitting directory `/etc/hp'
cp: omitting directory `/etc/httpd'
~/dir2 $ ll
total 16
-rw-r--r--. 1 root root 9 May 1 20:26 host.conf
-rw-r--r--. 1 root root 207 May 1 20:26 hosts
-rw-r--r--. 1 root root 370 May 1 20:26 hosts.allow
-rw-r--r--. 1 root root 460 May 1 20:26 hosts.deny
~/dir2 $ git init
Initialized empty Git repository in /root/dir2/.git/
~/dir2 $ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# host.conf
# hosts
# hosts.allow
# hosts.deny
nothing added to commit but untracked files present (use "git add" to track)
~/dir2 $ git add *
~/dir2 $ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: host.conf
# new file: hosts
# new file: hosts.allow
# new file: hosts.deny
#
~/dir2 $ git commit
[master (root-commit) 053c728] This is the initial file commit for my file ref rence
4 files changed, 32 insertions(+), 0 deletions(-)
create mode 100644 host.conf
create mode 100644 hosts
create mode 100644 hosts.allow
create mode 100644 hosts.deny
0 comments:
Post a Comment