2013年5月16日 星期四

[git]取消 git add 之後 的 file / remove add file(stage) to unstage


常常有時候我們在使用git add 後,並不想要真的在這次commit提交這幾個file。
在這個 status內,我們可以使用 git rm --cache ... 去unstage


$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached ..." to unstage)
#
# new file: .gitignore
# new file: alsox/alsoxmapper1.py
# new file: alsox/alsoxmapper2.py
# new file: alsox/alsoxreduce1.py
# new file: alsox/alsoxreduce2.py
# new file: alsox/gendata.py
# new file: alsox/mapper.py
# new file: alsox/mapper2.py
# new file: alsox/mapper2_1.py
# new file: alsox/memo
# new file: alsox/pdata1
# new file: alsox/reduce.py
# new file: alsox/reduce2.py
# new file: alsox/reduce2_1.py
# new file: alsox/reduce_index.py
# new file: alsox/staget215in
# new file: alsox/staget2in
# new file: alsox/tmp
#
# Untracked files:
# (use "git add ..." to include in what will be committed)
#
# mrtest/


------

$ git rm --cache `git status | grep "new file" | grep "alsox" | awk '{print $4}'`
rm 'alsox/alsoxmapper1.py'
rm 'alsox/alsoxmapper2.py'
rm 'alsox/alsoxreduce1.py'
rm 'alsox/alsoxreduce2.py'
rm 'alsox/gendata.py'
rm 'alsox/mapper.py'
rm 'alsox/mapper2.py'
rm 'alsox/mapper2_1.py'
rm 'alsox/memo'
rm 'alsox/pdata1'
rm 'alsox/reduce.py'
rm 'alsox/reduce2.py'
rm 'alsox/reduce2_1.py'
rm 'alsox/reduce_index.py'
rm 'alsox/staget215in'
rm 'alsox/staget2in'
rm 'alsox/tmp'

沒有留言:

張貼留言