Git -



VCS git .

.

commit

Jerry . . git checkout . .

[jerry@CentOS src]$ pwd
/home/jerry/jerry_repo/project/src

[jerry@CentOS src]$ git status -s
M string_operations.c

[jerry@CentOS src]$ git checkout string_operations.c

[jerry@CentOS src]$ git status s

git checkout . Tom . git checkout

[tom@CentOS src]$ pwd
/home/tom/top_repo/project/src

[tom@CentOS src]$ ls -1
Makefile
string_operations.c

[tom@CentOS src]$ rm string_operations.c

[tom@CentOS src]$ ls -1
Makefile

[tom@CentOS src]$ git status -s
D string_operations.c

Fit D .

[tom@CentOS src]$ git checkout string_operations.c

[tom@CentOS src]$ ls -1
Makefile
string_operations.c

[tom@CentOS src]$ git status -s

: commit .

Staging Area

git add ) ( staging area . git checkout

Git head pointer commit ) commit pointer ( . staging area git checkout head pointer . working tree reset staging area

Tom . git status staging area ) git add

tom@CentOS src]$ pwd
/home/tom/top_repo/project/src
# Unmodified file

[tom@CentOS src]$ git status -s

# Modify file and view its status.
[tom@CentOS src]$ git status -s
M string_operations.c

[tom@CentOS src]$ git add string_operations.c

Git status staging area git checkout git status

[tom@CentOS src]$ git checkout HEAD -- string_operations.c

[tom@CentOS src]$ git status -s

head pointer git reset

1 . git reset reset . reset

head pointer reset

git Tutorial git Tutorial

Soft

branch head ponter commit . git reset -soft commit ID head pointer, reset

commit ID, head pointer branch master branch .git/refs/heads/master git log-1

[jerry@CentOS project]$ cat .git/refs/heads/master
577647211ed44fe2ae479427a0668a4f12ed71a1

git log -2 commit ID commit ID

[jerry@CentOS project]$ git log -2

commit 577647211ed44fe2ae479427a0668a4f12ed71a1
Author: Tom Cat <tom@tutorialspoint.com>
Date: Wed Sep 11 10:21:20 2013 +0530

Removed executable binary


commit 29af9d45947dc044e33d69b9141d8d2dad37cc62
Author: Jerry Mouse <jerry@tutorialspoint.com>
Date: Wed Sep 11 10:16:25 2013 +0530

Added compiled binary

HEAD POINTER reset

[jerry@CentOS project]$ git reset --soft HEAD~

head pointer commit, reset . git/refs/heads/master file

[jerry@CentOS project]$ cat .git/refs/heads/master
29af9d45947dc044e33d69b9141d8d2dad37cc62

commit ID

jerry@CentOS project]$ git log -2

:

commit 29af9d45947dc044e33d69b9141d8d2dad37cc62
Author: Jerry Mouse <jerry@tutorialspoint.com>
Date: Wed Sep 11 10:16:25 2013 +0530

Added compiled binary


commit 94f7b26005f856f1a1b733ad438e97a0cd509c1a
Author: Jerry Mouse <jerry@tutorialspoint.com>
Date: Wed Sep 11 10:08:01 2013 +0530

Added Makefile and renamed strings.c to string_operations.c

mixed

git reset --mixed staging area commit . staging area . . git reset git reset --mixed

hard

--hard staging area head pointer commit commit reset

commit ID

[jerry@CentOS src]$ pwd
/home/jerry/jerry_repo/project/src

[jerry@CentOS src]$ git log -1

:

commit 577647211ed44fe2ae479427a0668a4f12ed71a1
Author: Tom Cat <tom@tutorialspoint.com>
Date: Wed Sep 11 10:21:20 2013 +0530

Removed executable binary

Jerry

[jerry@CentOS src]$ head -2 string_operations.c
/* This line be removed by git reset operation */
#include <stdio.h>

git status :

[jerry@CentOS src]$ git status -s
M string_operations.c

Jerry staging area :

[jerry@CentOS src]$ git add string_operations.c
[jerry@CentOS src]$ git status

:

# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
#
modified: string_operations.c
#

git status staging area . git reset --hard

[jerry@CentOS src]$ git reset --hard 577647211ed44fe2ae479427a0668a4f12ed71a1

HEAD is now at 5776472 Removed executable binary

staging area

[jerry@CentOS src]$ git status -s

git status staging area

[jerry@CentOS src]$ head -2 string_operations.c
#include <stdio.h>

head

Advertisements