總網頁瀏覽量

關於我自己

我的相片
人生的必修課是接受無常,人生的選修課是放下執著。

2013年12月10日 星期二

【GIT】回復修改 reset / checkout

去除最後一筆commit
$git log
commit 1a66bbbd5628c754b8628c754b8539b94d51684beb0e88407
Author: A_Chang
Date:  Fri Mar 30 23:59:59 2012 +0800
audit

commit 2a66bbbd5628c754b8628c754b8539b94d51684beb0e88407
Author: B_Chang
Date:  Fri Mar 29 23:59:59 2012 +0800
audit
$git reset --soft HEAD^
$git log
commit 2a66bbbd5628c754b8628c754b8539b94d51684beb0e88407
Author: B_Chang
Date:  Fri Mar 29 23:59:59 2012 +0800
audit


去除git add的動作
【方法一】
$git log
commit 1a66bbbd5628c754b8628c754b8539b94d51684beb0e88407
Author: A_Chang
Date:  Fri Mar 30 23:59:59 2012 +0800
audit

commit 2a66bbbd5628c754b8628c754b8539b94d51684beb0e88407
Author: B_Chang
Date:  Fri Mar 29 23:59:59 2012 +0800
audit
$git reset 1a66bbbd5628 --mixed
$git log
commit 2a66bbbd5628c754b8628c754b8539b94d51684beb0e88407
Author: B_Chang
Date:  Fri Mar 29 23:59:59 2012 +0800
audit
$git status
# Untracked files:
# (use "git add <file>..." to include in what will be commited)
#
#  packages/apps/Music/Android.mk

【方法二】
$git status
# Changes to be committed: 
# (use "git reset HEAD <file>..." to unstage)
#
#  modified: packages/apps/Music/Android.mk


$git reset  packages/apps/Music/Android.mk
$git status
# Untracked files:
# (use "git add <file>..." to include in what will be commited)
#
#  packages/apps/Music/Android.mk


去除檔案的修改
【方法一】
$git log
commit 1a66bbbd5628c754b8628c754b8539b94d51684beb0e88407
Author: A_Chang
Date:  Fri Mar 30 23:59:59 2012 +0800
audit

commit 2a66bbbd5628c754b8628c754b8539b94d51684beb0e88407
Author: B_Chang
Date:  Fri Mar 29 23:59:59 2012 +0800
audit
$git reset 1a66bbbd5628 --hard
$git log
commit 2a66bbbd5628c754b8628c754b8539b94d51684beb0e88407
Author: B_Chang
Date:  Fri Mar 29 23:59:59 2012 +0800
audit
$git status
# Untracked files:
# (use "git add <file>..." to include in what will be commited)
#

【方法二】
$git status
# Changes to be committed: 
# (use "git reset HEAD <file>..." to unstage)
#
#  modified: packages/apps/Music/Android.mk


$git checkout  packages/apps/Music/Android.mk
$git status
# Untracked files:
# (use "git add <file>..." to include in what will be commited)
#



沒有留言:

張貼留言