Ignore on commit

11 messages, 7 authors, 2016-06-15 · open the first message on its own page

Ignore on commit

From: Marco Craveiro <hidden>
Date: 2016-06-15 22:54:56

Hello gitters,

One of the very (very) few features I miss in svn is "ignore on
commit" (or, more generally, changelists). I'm not sure if this has
been discussed in the past - google failed me a bit due to spurious
matches - but I personally find it quite useful. The feature is
described here [1] (and graphically, here [2]).

The gist of it is, one can mark certain files as "ignore on commit"
and they get placed on a "special list" which shows up on status.
These lists are effectively a sub-division of modified (but not
staged). Up till now I have found the staging area to be quite
sufficient, but recently I hit a use case where I was modifying a
large number of files; some modifications were hacks required to get
the build to work but were not meant to ever get checked in, most
other files had real work. In cases like this its really useful to
mark the hacked files as "ignore on commit", so that a) we don't lose
track of them (as one would with git ignore, or with [4]) but b) we
won't check them in by mistake.

I found some tips on how to survive without change lists ([3], [4])
but they are a bit more cumbersome. Has this feature been discussed?

Thanks a lot for an amazing piece of software, and thanks for your time.

Cheers

Marco
-- 
So young, and already so unknown -- Pauli

blog: http://mcraveiro.blogspot.com

[1] http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.changelist.html
[2] http://blog.baljeetsingh.net/2009/02/tips-tricks-svn-ignore-on-commit.html
[3] http://stackoverflow.com/questions/10606809/git-equivalence-of-svn-changelist
[4] http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

Re: Ignore on commit

From: Marco Craveiro <hidden>
Date: 2016-06-15 22:54:56

<ignore on commit>
I'm not sure to follow everything... But looks like:

   $ git add -p

or

   $ git add -i

should do what you want, no?

You select the hunks to commit, let over the "hacks" and then

   $ git commit
Similar but not quite; the idea is that you know that there is some
code (I'm just talking about files here, so lets ignore hunks for the
moment) which is normally checked in but for a period of time you want
it ignored. So you don't want it git ignored but at the same time you
don't want to see these files in the list of modified files. The
changelist concept allows you to "move" the files out of the way from
the main modified section until you are ready to commit them. Perhaps
an imaginary git status would help:

# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	modified:   some_staged_file.h
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   some_modified_file.h
#
# Changes ignored on commit:
#
#	modified:   some_other_modified_file.h

Such that if you now did a git add -A, some_modified_file.h would then
be staged but some_other_modified_file.h would stay put. Of course the
name "ignored on commit" makes little sense in git terms, but I'm
using it here as its the svn term. Its a "modified but temporarily
ignored" or something.

Cheers

Marco
-- 
So young, and already so unknown -- Pauli

blog: http://mcraveiro.blogspot.com

Re: Ignore on commit

From: Pascal Obry <hidden>
Date: 2016-06-15 22:54:56

I'm not sure to follow everything... But looks like:

   $ git add -p

or

   $ git add -i

should do what you want, no?

You select the hunks to commit, let over the "hacks" and then

   $ git commit

-- 

  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://v2p.fr.eu.org
  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B

Re: Ignore on commit

From: Andrew Wong <hidden>
Date: 2016-06-15 22:54:56

On 10/04/2012 05:20 PM, Marco Craveiro wrote:
Similar but not quite; the idea is that you know that there is some
code (I'm just talking about files here, so lets ignore hunks for the
moment) which is normally checked in but for a period of time you want
it ignored. So you don't want it git ignored but at the same time you
don't want to see these files in the list of modified files.
The way I usually handle this scenario is by actually making a temporary 
commit with those temporary changes. And whenever I make a permanent 
commit, I'll use "rebase -i" to rearrange the commits so that all my 
permanent commits go before my temporary commits. So when I need to 
push, I'll just push up till before my temporary commits.

This way I also get to make permanent changes in files that I have 
temporary changes.

Re: Ignore on commit

From: Andrew Ardill <hidden>
Date: 2016-06-15 22:54:57

On 5 October 2012 07:20, Marco Craveiro [off-list ref] wrote:
...
Similar but not quite; the idea is that you know that there is some
code (I'm just talking about files here, so lets ignore hunks for the
moment) which is normally checked in but for a period of time you want
it ignored. So you don't want it git ignored but at the same time you
don't want to see these files in the list of modified files.
What is the reason git ignore is no good in this case? Is it simply
that you can't see the ignored files in git status, or is it that
adding and removing entries to .gitignore is too cumbersome? If it's
the latter you could probably put together a simple shell wrapper to
automate the task, as otherwise it seems like git ignore does what you
need.

Regards,

Andrew Ardill

Re: Ignore on commit

From: demerphq <hidden>
Date: 2016-06-15 22:54:57

On 5 October 2012 03:00, Andrew Ardill [off-list ref] wrote:
On 5 October 2012 07:20, Marco Craveiro [off-list ref] wrote:
quoted
...
Similar but not quite; the idea is that you know that there is some
code (I'm just talking about files here, so lets ignore hunks for the
moment) which is normally checked in but for a period of time you want
it ignored. So you don't want it git ignored but at the same time you
don't want to see these files in the list of modified files.
What is the reason git ignore is no good in this case? Is it simply
that you can't see the ignored files in git status, or is it that
adding and removing entries to .gitignore is too cumbersome? If it's
the latter you could probably put together a simple shell wrapper to
automate the task, as otherwise it seems like git ignore does what you
need.
Git ignore doesn't ignore tracked files.

Yves


-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Re: Ignore on commit

From: Sitaram Chamarty <hidden>
Date: 2016-06-15 22:54:57

On Fri, Oct 5, 2012 at 7:05 AM, demerphq [off-list ref] wrote:
On 5 October 2012 03:00, Andrew Ardill [off-list ref] wrote:
quoted
On 5 October 2012 07:20, Marco Craveiro [off-list ref] wrote:
quoted
...
Similar but not quite; the idea is that you know that there is some
code (I'm just talking about files here, so lets ignore hunks for the
moment) which is normally checked in but for a period of time you want
it ignored. So you don't want it git ignored but at the same time you
don't want to see these files in the list of modified files.
What is the reason git ignore is no good in this case? Is it simply
that you can't see the ignored files in git status, or is it that
adding and removing entries to .gitignore is too cumbersome? If it's
the latter you could probably put together a simple shell wrapper to
automate the task, as otherwise it seems like git ignore does what you
need.
Git ignore doesn't ignore tracked files.
would 'git update-index --assume-unchanged' work in this case?  Didn't
see it mentioned in any of the replies so far (but I have never used
it myself)

Re: Ignore on commit

From: Andrew Ardill <hidden>
Date: 2016-06-15 22:54:57

On 5 October 2012 12:20, Sitaram Chamarty [off-list ref] wrote:
On Fri, Oct 5, 2012 at 7:05 AM, demerphq [off-list ref] wrote:
quoted
On 5 October 2012 03:00, Andrew Ardill [off-list ref] wrote:
quoted
On 5 October 2012 07:20, Marco Craveiro [off-list ref] wrote:
quoted
...
Similar but not quite; the idea is that you know that there is some
code (I'm just talking about files here, so lets ignore hunks for the
moment) which is normally checked in but for a period of time you want
it ignored. So you don't want it git ignored but at the same time you
don't want to see these files in the list of modified files.
What is the reason git ignore is no good in this case? Is it simply
that you can't see the ignored files in git status, or is it that
adding and removing entries to .gitignore is too cumbersome? If it's
the latter you could probably put together a simple shell wrapper to
automate the task, as otherwise it seems like git ignore does what you
need.
Git ignore doesn't ignore tracked files.
would 'git update-index --assume-unchanged' work in this case?  Didn't
see it mentioned in any of the replies so far (but I have never used
it myself)
From the help page:
--assume-unchanged, --no-assume-unchanged
    ...

    This option can be also used as a coarse file-level mechanism to
ignore uncommitted changes in tracked files (akin to what .gitignore
    does for untracked files).

Seems like it does everything required. I tested and it correctly
hides changes that I want hidden. The only thing I can't see how to do
is get git status to show files with the assume unchanged  bit set. I
think there is no way currently, but that might be a nice addition to
make the initial request feature complete. It could show either all
files with the bit set, or files with the bit set that have been
changed (or this could be configurable).

Regards,

Andrew Ardill

Re: Ignore on commit

From: Philip Oakley <hidden>
Date: 2016-06-15 22:54:57

From: "Andrew Ardill" <redacted>
On 5 October 2012 07:20, Marco Craveiro [off-list ref] 
wrote:
quoted
...
Similar but not quite; the idea is that you know that there is some
code (I'm just talking about files here, so lets ignore hunks for the
moment) which is normally checked in but for a period of time you 
want
it ignored. So you don't want it git ignored but at the same time you
don't want to see these files in the list of modified files.
What is the reason git ignore is no good in this case? Is it simply
that you can't see the ignored files in git status, or is it that
adding and removing entries to .gitignore is too cumbersome? If it's
the latter you could probably put together a simple shell wrapper to
automate the task, as otherwise it seems like git ignore does what you
need.
IIUC the files are already tracked, and a variant of ' git 
update-index --assume-unchanged' is being requested, so that the command 
doesn't need to be repeated if they checkuout / swap branches (which 
assumes I've understood the effect of such an index change correctly)
Regards,

Andrew Ardill
--

Re: Ignore on commit

From: Marco Craveiro <hidden>
Date: 2016-06-15 22:54:57

<git update-index --assume-unchanged>
From the help page:

--assume-unchanged, --no-assume-unchanged
    ...

    This option can be also used as a coarse file-level mechanism to
ignore uncommitted changes in tracked files (akin to what .gitignore
    does for untracked files).

Seems like it does everything required. I tested and it correctly
hides changes that I want hidden. The only thing I can't see how to do
is get git status to show files with the assume unchanged  bit set. I
think there is no way currently, but that might be a nice addition to
make the initial request feature complete. It could show either all
files with the bit set, or files with the bit set that have been
changed (or this could be configurable).
This is indeed the solution outlined in [4] on my original post:

http://gitready.com/intermediate/2009/02/18/temporarily-ignoring-files.html

The presence in git status is quite important or else one has to
change the regular workflow with a second status command.

Cheers

Marco
-- 
So young, and already so unknown -- Pauli

blog: http://mcraveiro.blogspot.com

Re: Ignore on commit

From: Pascal Obry <hidden>
Date: 2016-06-15 22:54:57

Marco,
Similar but not quite; the idea is that you know that there is some
code (I'm just talking about files here, so lets ignore hunks for the
moment) which is normally checked in but for a period of time you want
it ignored. 
Got it thanks! Would be useful some time indeed.

-- 

  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://v2p.fr.eu.org
  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help