Previous Git Blogs
1. Intialize git repostiory
2. First Commit
3. Two tree architecture and Three tree architecture
4. Best basic practices for writing commit messages
5. Viewing the commit logs
6. Git Basic WorkFlow
7. What is HEAD pointer in GIT
8. Git Configuration
9. Viewing history
10. Updating a file and adding it to repository
11. Viewing history
12. Git Config, Add, Commit, View, Diff summary
Let see how many file's do I have in my local working directory
naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ ls
two files exits my_first_file and readme.txt
naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ ls
naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ gedit my_first_file
naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ gedit readme.txt
open each file and edit it
if I do
git status
I got two pending changes in my working copy
Git Display
On branch master
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
modified: my_first_file
modified: readme.txt
they might be completely different, I did two things at once.
Now we would like two stage these as two different commits
naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git add my_first_file
naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git status
On branch master
Changes to be committed:
(use "git reset HEAD ..." to unstage)
modified: my_first_file
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
modified: readme.txt
you can see my_first_file changes has been staged but readme.txt are not staged
Now I will commit it my_first_file
naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git commit -m"fied bugs-1098"
Git Display
[master c4bf6fc] fied bugs-1098
1 file changed, 1 insertion(+)
Now I will add the readme.txt
naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git add readme.txt
Now commit it
naveen@naveen:/var/www/html/RND/symfony_sites/symfony_todoapp$ git commit -m"added additional information regarding new features in readme"
Git Display
[master 4007396] added additional information regarding new features in readme
1 file changed, 1 insertion(+)
Basically staging helps us to break commits into logical units
0 Comment(s)