threads / discuss / 17249

how to omit rename file when commit

Subject: how to omit rename file when commit

## tl;dr

5 messages between Jan 19, 2009 and Jan 19, 2009.

replies: 4people: 4as markdown or json

Frank Li· Jan 19, 2009, 09:13 UTC · lore

For example there are a file a.c at git repository. use git mv a.c b.c

git status: # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # renamed: a.c -> b.c

If we don't want to stage this change at this commit,  what can I do?
Junio C Hamano· Jan 19, 2009, 09:16 UTC · re: Frank Li · lore

Re: how to omit rename file when commit

"Frank Li" <lznuaa@gmail.com> writes:
Show 12 quoted lines
> For example there are a file a.c at git repository.
> use
> git mv a.c b.c
>
> git status:
> # On branch master
> # Changes to be committed:
> #   (use "git reset HEAD <file>..." to unstage)
> #
> #       renamed:    a.c -> b.c
>
> If we don't want to stage this change at this commit,  what can I do?

I may be misunderstanding what you want to do, but wouldn't "git mv b.c a.c" undo whatever you did?

Frank Li· Jan 19, 2009, 09:35 UTC · re: Junio C Hamano · lore

Re: how to omit rename file when commit

For example: there are 2 file. a.c and e.c I modify e.c. and git mv a.c b.c

git update-index e.c
I just want to commit e.c and don't commit rename(a.c -> b.c)

I am debuging a tortoisegit. at commit dialog, there will be show all changed as [x] rename (a.c => b.c) [x] modify (e.c) button [OK]

assume user uncheck rename []rename (a.c=>b.c) [x]modify (e.c)

then click okay.

I don't know use which git command to handle this case. if git mv b.c a.c, local working copy will be changed.

2009/1/19 Junio C Hamano <gitster@pobox.com>:
Show 19 quoted lines
> "Frank Li" <lznuaa@gmail.com> writes:
>
>> For example there are a file a.c at git repository.
>> use
>> git mv a.c b.c
>>
>> git status:
>> # On branch master
>> # Changes to be committed:
>> #   (use "git reset HEAD <file>..." to unstage)
>> #
>> #       renamed:    a.c -> b.c
>>
>> If we don't want to stage this change at this commit,  what can I do?
>
> I may be misunderstanding what you want to do, but wouldn't "git mv b.c
> a.c" undo whatever you did?
>
>
Jakub Narebski· Jan 19, 2009, 11:01 UTC · re: Frank Li · lore

Re: how to omit rename file when commit

"Frank Li" <lznuaa@gmail.com> writes:
Show 8 quoted lines
> For example:
> there are 2 file. a.c and e.c
> I modify e.c.
> and git mv a.c b.c
> 
> git update-index e.c
> 
> I just want to commit e.c and don't commit rename(a.c -> b.c)
The simplest way (but I'm not sure if it is what you want) would be
  $ git commit e.c
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Boyd Stephen Smith Jr.· Jan 19, 2009, 17:41 UTC · re: Frank Li · lore

Re: how to omit rename file when commit

On Monday 2009 January 19 03:35:41 you wrote:
Show 8 quoted lines
>For example:
>there are 2 file. a.c and e.c
>I modify e.c.
>and git mv a.c b.c
>
>git update-index e.c
>
>I just want to commit e.c and don't commit rename(a.c -> b.c)
Here, it looks like all you need to do is follow the instructions given by git 
status--use "git reset HEAD" on each file you want unstaged:
$ rm -rf test && mkdir test
$ cd test
/home/bss/test
$ git init
Initialized empty Git repository in /home/bss/test/.git/
$ echo b > a.c; echo d > e.c
$ git add a.c b.c e.c
$ git commit -m 'Setup'
Created initial commit fc9d26e: Setup
 2 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 a.c
 create mode 100644 e.c
$ git mv a.c b.c
$ echo e > e.c
$ git add e.c
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       renamed:    a.c -> b.c
#       modified:   e.c
#
$ git reset HEAD -- a.c b.c
a.c: locally modified
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   e.c
#
# Changed but not updated:
#   (use "git add/rm <file>..." to update what will be committed)
#
#       deleted:    a.c
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       b.c
$ git commit -m 'e.c: Fix typo'
Created commit c23b226: e.c: Fix typo
 1 files changed, 1 insertions(+), 1 deletions(-)
$ git status
# On branch master
# Changed but not updated:
#   (use "git add/rm <file>..." to update what will be committed)
#
#       deleted:    a.c
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       b.c
no changes added to commit (use "git add" and/or "git commit -a")
HTH.
-- 
Boyd Stephen Smith Jr.                     ,= ,-_-. =. 
bss@iguanasuicide.net                     ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' 
http://iguanasuicide.net/                      \_/     

← back to recent threads