Re: "git rm" is not a valid merge resolution?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



W dniu 21.03.2011 19:35, Matthieu Moy pisze:
> Piotr Krukowiecki <piotr.krukowiecki@xxxxxxxxx> writes:
> 
>> Hi,
>>
>> git-status shows a hint that says
>>     use "git add/rm <file>..." as appropriate to mark resolution
>>  
>> But if I "git rm file" the file gets deleted. Is this really the 
>> appropriate merge resolution?
> 
> In most cases, no, but when you have a modify/delete conflict for
> example, "git rm" is one of the candidates to resolve the conflict. The
> hint gives the general case.

I think this is not completely true. You can stage removal of a file with
git add, but it's harder than use of git rm.

This is something I don't understand. Why is there a difference between
removing files and (adding files or removing content)?

You must use special flags to "git add" to remove files, while you don't
need such flags to add file or remove content.

All changes are tracked. You won't loose your data if you remove the
file by mistake. It is the same as remove some content by mistake.


Is it caused by the name of the command ("add")? Some people would be
surprised if "git add" marked removed file for removal. But I think
some would be already surprised that you have to "add" your changes.

Or maybe it is caused by the fact that "git tracks content" (if I
remember correctly)? I don't see a problem here. The command just
tells git what content it should track. "git add" does not say
"track this change (file path addition/file deletion)" but
"track this file path content", so if the file got deleted there
is nothing to track.


Maybe the command should be named "stage". You should stage your
changes. Add the file deletion is the same change as file addition.

You would do
   
    git stage addedfile
    git stage deletedfile
    git stage changedfile

This would be consistent.

(For me it doesn't need to be "stage" name. It could be handled by
"add").


Currently it works like this:

   git add untracked # Adds untracked file 
   git add . # Adds all untracked files

   rm tracked
   git add tracked # Does not stage the delete
   git add . # Does not stage the delete
   git add -A tracked # This works - stages deletion of tracked file

   git add -u # Stages all tracked changes, also new/deleted tracked files
   git add -A # Stages all changes, also new/deleted untracked files

   # No way to do following (without listing files explicitly):

   # 1. Added several new files, but has also several tracked files changed
   #    and want to only add new files

   # 2. Removed several tracked files, but has also several other tracked
   #    files changed and want to only remove deleted files. 

-- 
Piotr Krukowiecki
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]