fix description of "git rm" and "git mv" to mention --cached
using git rm removes the file from the index AND the working directory, so trying to mv the file to the new name wouldn't actually work. If you use "git rm --cached" the file still exists to be worked with.
This commit is contained in:
parent
d0aaa08f24
commit
ec06c8961f
@ -701,11 +701,13 @@ M hello.rb
|
|||||||
included in the next commit snapshot, thereby effectively deleting it.</p>
|
included in the next commit snapshot, thereby effectively deleting it.</p>
|
||||||
|
|
||||||
<p>By default, a <code>git rm file</code> will remove the file from the
|
<p>By default, a <code>git rm file</code> will remove the file from the
|
||||||
staging area entirely and also off your disk (the working directory).</p>
|
staging area entirely and also off your disk (the working directory). To
|
||||||
|
leave the file in the working directory, you can use <code>git rm --cached
|
||||||
|
</code>.</p>
|
||||||
|
|
||||||
<h4>
|
<h4>
|
||||||
git mv
|
git mv
|
||||||
<small>git rm orig; mv orig new; git add new</small>
|
<small>git rm --cached orig; mv orig new; git add new</small>
|
||||||
</h4>
|
</h4>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@ -715,7 +717,7 @@ M hello.rb
|
|||||||
snapshot and another file was added to the next one and the contents are
|
snapshot and another file was added to the next one and the contents are
|
||||||
similar, Git figures it was most likely a rename. So, although the
|
similar, Git figures it was most likely a rename. So, although the
|
||||||
<code>git mv</code> command exists, it is superfluous - all it does is a
|
<code>git mv</code> command exists, it is superfluous - all it does is a
|
||||||
<code>git rm</code>, moves the file on disk, then runs a
|
<code>git rm --cached</code>, moves the file on disk, then runs a
|
||||||
<code>git add</code> on the new file. You don't really need to use it, but
|
<code>git add</code> on the new file. You don't really need to use it, but
|
||||||
if it's easier, feel free.
|
if it's easier, feel free.
|
||||||
</p>
|
</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user