* Documentation: user-manual: "git commit -a" doesn't motivate .gitignore @ 2008-08-06 21:22 Jonathan Nieder 2008-08-06 21:47 ` Miklos Vajna 2008-08-07 12:24 ` Documentation: user-manual: "git commit -a" doesn't motivate .gitignore J. Bruce Fields 0 siblings, 2 replies; 10+ messages in thread From: Jonathan Nieder @ 2008-08-06 21:22 UTC (permalink / raw) To: git "git commit -a" ignores untracked files and follows all tracked files, regardless of whether they are listed in .gitignore. So don't use it to motivate gitignore. Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu> --- I noticed this while reading through the git-scm book, which looks very good. If I am missing something, I would be very happy to know. Maybe the sort of person that wants to track the exact contents of the working tree would prefer "git commit -a -i ." over "git commit -a"? Documentation/user-manual.txt | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt index 43f4e39..f421689 100644 --- a/Documentation/user-manual.txt +++ b/Documentation/user-manual.txt @@ -1128,8 +1128,8 @@ This typically includes files generated by a build process or temporary backup files made by your editor. Of course, 'not' tracking files with git is just a matter of 'not' calling "`git-add`" on them. But it quickly becomes annoying to have these untracked files lying around; e.g. they make -"`git add .`" and "`git commit -a`" practically useless, and they keep -showing up in the output of "`git status`". +"`git add .`" practically useless, and they keep showing up in the output of +"`git status`". You can tell git to ignore certain files by creating a file called .gitignore in the top level of your working directory, with contents such as: -- 1.6.0.rc1.228.ge730 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: Documentation: user-manual: "git commit -a" doesn't motivate .gitignore 2008-08-06 21:22 Documentation: user-manual: "git commit -a" doesn't motivate .gitignore Jonathan Nieder @ 2008-08-06 21:47 ` Miklos Vajna 2008-08-06 22:29 ` Jonathan Nieder 2008-08-07 12:24 ` Documentation: user-manual: "git commit -a" doesn't motivate .gitignore J. Bruce Fields 1 sibling, 1 reply; 10+ messages in thread From: Miklos Vajna @ 2008-08-06 21:47 UTC (permalink / raw) To: Jonathan Nieder; +Cc: git [-- Attachment #1: Type: text/plain, Size: 321 bytes --] On Wed, Aug 06, 2008 at 04:22:00PM -0500, Jonathan Nieder <jrnieder@uchicago.edu> wrote: > happy to know. Maybe the sort of person that wants to track the > exact contents of the working tree would prefer > "git commit -a -i ." over "git commit -a"? If you want so, then probably git add -A && git commit is easier. [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Documentation: user-manual: "git commit -a" doesn't motivate .gitignore 2008-08-06 21:47 ` Miklos Vajna @ 2008-08-06 22:29 ` Jonathan Nieder 2008-08-06 22:54 ` Jonathan Nieder 2008-08-07 0:15 ` [PATCH] Documentation: clarify that git-commit only works with tracked files Jonathan Nieder 0 siblings, 2 replies; 10+ messages in thread From: Jonathan Nieder @ 2008-08-06 22:29 UTC (permalink / raw) To: Miklos Vajna; +Cc: git Miklos Vajna wrote: > On Wed, Aug 06, 2008 at 04:22:00PM -0500, Jonathan Nieder <jrnieder@uchicago.edu> wrote: > > happy to know. Maybe the sort of person that wants to track the > > exact contents of the working tree would prefer > > "git commit -a -i ." over "git commit -a"? > > If you want so, then probably git add -A && git commit is easier. Hmm. I don't want it myself, but it seemed like the spirit behind the lines I mentioned in the user manual. Maybe something like this (untested) would serve such people even better. If anyone actually wants this, I'd be glad to make tests and document it. Thanks for the pointer. -- snipsnip -- Subject: git commit --addremove: add and update all files This makes git commit -A a shortcut for git add -A && git commit. It saves keystrokes, but more importantly it seems to be conceptually the right thing thing for users who have perfect .gitignore files and want to ignore the index. --- builtin-commit.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/builtin-commit.c b/builtin-commit.c index b783e6e..e3f645e 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -50,7 +50,8 @@ static char *logfile, *force_author; static const char *template_file; static char *edit_message, *use_message; static char *author_name, *author_email, *author_date; -static int all, edit_flag, also, interactive, only, amend, signoff; +static int all, addremove, edit_flag, also, interactive, only; +static int amend, signoff; static int quiet, verbose, no_verify, allow_empty; static char *untracked_files_arg; /* @@ -99,6 +100,7 @@ static struct option builtin_commit_options[] = { OPT_GROUP("Commit contents options"), OPT_BOOLEAN('a', "all", &all, "commit all changed files"), + OPT_BOOLEAN('A', "addremove", &addremove, "commit all changed files, including untracked"), OPT_BOOLEAN('i', "include", &also, "add specified files to index for commit"), OPT_BOOLEAN(0, "interactive", &interactive, "interactively add files"), OPT_BOOLEAN('o', "only", &only, "commit only specified files"), @@ -788,8 +790,8 @@ static int parse_and_validate_options(int argc, const char *argv[], free(enc); } - if (!!also + !!only + !!all + !!interactive > 1) - die("Only one of --include/--only/--all/--interactive can be used."); + if (!!also + !!only + !!all + !!addremove + !!interactive > 1) + die("Only one of --include/--only/--all/--addremove/--interactive can be used."); if (argc == 0 && (also || (only && !amend))) die("No paths with --include/--only does not make sense."); if (argc == 0 && only && amend) @@ -823,6 +825,16 @@ static int parse_and_validate_options(int argc, const char *argv[], else if (interactive && argc > 0) die("Paths with --interactive does not make sense."); + if (addremove) { + all = 1; + also = 1; + } + if (addremove && !argc) { + static const char *here[2] = {".", NULL }; + argc = 1; + *argv = here; + } + return argc; } -- 1.6.0.rc1.228.ge730 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: Documentation: user-manual: "git commit -a" doesn't motivate .gitignore 2008-08-06 22:29 ` Jonathan Nieder @ 2008-08-06 22:54 ` Jonathan Nieder 2008-08-07 0:15 ` [PATCH] Documentation: clarify that git-commit only works with tracked files Jonathan Nieder 1 sibling, 0 replies; 10+ messages in thread From: Jonathan Nieder @ 2008-08-06 22:54 UTC (permalink / raw) To: Miklos Vajna; +Cc: git On Wed, 6 Aug 2008, Jonathan Nieder wrote: > Subject: git commit --addremove: add and update all files > > This makes git commit -A a shortcut for git add -A && git commit. It > saves keystrokes, but more importantly it seems to be conceptually the > right thing thing for users who have perfect .gitignore files and want > to ignore the index. > --- > builtin-commit.c | 18 +++++++++++++++--- > 1 files changed, 15 insertions(+), 3 deletions(-) I was too hasty - the patch is insane in a number of ways. But hopefully the intent is clear :) Jonathan ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH] Documentation: clarify that git-commit only works with tracked files 2008-08-06 22:29 ` Jonathan Nieder 2008-08-06 22:54 ` Jonathan Nieder @ 2008-08-07 0:15 ` Jonathan Nieder 2008-08-07 0:39 ` Johannes Schindelin 1 sibling, 1 reply; 10+ messages in thread From: Jonathan Nieder @ 2008-08-07 0:15 UTC (permalink / raw) To: Miklos Vajna; +Cc: git A user unfamiliar with CVS might not realize that a git-add is needed before commiting new files. So emphasize that "git commit <path>..." only commits files already in the index. Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu> --- I keep on forgetting and getting annoyed when "git commit newfile.c" does not work. From the same confusion I suggested git commit -A without really thinking about what it meant. This change should make the behavior easier to understand and remember. Thanks for the help. Documentation/git-commit.txt | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/git-commit.txt b/Documentation/git-commit.txt index 0e25bb8..9b00ccb 100644 --- a/Documentation/git-commit.txt +++ b/Documentation/git-commit.txt @@ -27,9 +27,10 @@ The content to be added can be specified in several ways: 2. by using 'git-rm' to remove files from the working tree and the index, again before using the 'commit' command; -3. by listing files as arguments to the 'commit' command, in which - case the commit will ignore changes staged in the index, and instead - record the current content of the listed files; +3. by listing some known files as arguments to the 'commit' + command, in which case the commit will ignore changes staged + in the index and instead record the current content of the + listed files; 4. by using the -a switch with the 'commit' command to automatically "add" changes from all known files (i.e. all files that are already -- 1.6.0.rc1.91.gf0c3 ^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] Documentation: clarify that git-commit only works with tracked files 2008-08-07 0:15 ` [PATCH] Documentation: clarify that git-commit only works with tracked files Jonathan Nieder @ 2008-08-07 0:39 ` Johannes Schindelin 2008-08-07 1:14 ` Jonathan Nieder ` (2 more replies) 0 siblings, 3 replies; 10+ messages in thread From: Johannes Schindelin @ 2008-08-07 0:39 UTC (permalink / raw) To: Jonathan Nieder; +Cc: Miklos Vajna, git Hi, On Wed, 6 Aug 2008, Jonathan Nieder wrote: > A user unfamiliar with CVS might not realize that a git-add is > needed before commiting new files. Funny. I haven't used CVS for a while now, but I seem to remember that "cvs commit newfile.c" without a prior "cvs add newfile.c" is not allowed. Ciao, Dscho ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Documentation: clarify that git-commit only works with tracked files 2008-08-07 0:39 ` Johannes Schindelin @ 2008-08-07 1:14 ` Jonathan Nieder 2008-08-07 11:00 ` Miklos Vajna 2008-08-07 11:52 ` Peter Krefting 2 siblings, 0 replies; 10+ messages in thread From: Jonathan Nieder @ 2008-08-07 1:14 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Miklos Vajna, git Hi, On Thu, 7 Aug 2008, Johannes Schindelin wrote: > On Wed, 6 Aug 2008, Jonathan Nieder wrote: > > > A user unfamiliar with CVS might not realize that a git-add is > > needed before commiting new files. > > Funny. I haven't used CVS for a while now, but I seem to remember that > "cvs commit newfile.c" without a prior "cvs add newfile.c" is not allowed. Yes, this is a closely related statement: a user familiar with CVS should already know to add. :) Jonathan ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Documentation: clarify that git-commit only works with tracked files 2008-08-07 0:39 ` Johannes Schindelin 2008-08-07 1:14 ` Jonathan Nieder @ 2008-08-07 11:00 ` Miklos Vajna 2008-08-07 11:52 ` Peter Krefting 2 siblings, 0 replies; 10+ messages in thread From: Miklos Vajna @ 2008-08-07 11:00 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Jonathan Nieder, git [-- Attachment #1: Type: text/plain, Size: 459 bytes --] On Thu, Aug 07, 2008 at 02:39:59AM +0200, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote: > Funny. I haven't used CVS for a while now, but I seem to remember that > "cvs commit newfile.c" without a prior "cvs add newfile.c" is not allowed. But there is a difference. In most VCSes, you need 'add' once. In git you need add before every commit. Of course this should be clear after reading the "How to make a commit" part of the user manual. [-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] Documentation: clarify that git-commit only works with tracked files 2008-08-07 0:39 ` Johannes Schindelin 2008-08-07 1:14 ` Jonathan Nieder 2008-08-07 11:00 ` Miklos Vajna @ 2008-08-07 11:52 ` Peter Krefting 2 siblings, 0 replies; 10+ messages in thread From: Peter Krefting @ 2008-08-07 11:52 UTC (permalink / raw) To: Johannes Schindelin; +Cc: Git Mailing List Johannes Schindelin: > Funny. I haven't used CVS for a while now, but I seem to remember > that "cvs commit newfile.c" without a prior "cvs add newfile.c" is > not allowed. Only to add the file to revision control initially. After that, you just use commit to create new revisions. -- \\// Peter - http://www.softwolves.pp.se/ ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Documentation: user-manual: "git commit -a" doesn't motivate .gitignore 2008-08-06 21:22 Documentation: user-manual: "git commit -a" doesn't motivate .gitignore Jonathan Nieder 2008-08-06 21:47 ` Miklos Vajna @ 2008-08-07 12:24 ` J. Bruce Fields 1 sibling, 0 replies; 10+ messages in thread From: J. Bruce Fields @ 2008-08-07 12:24 UTC (permalink / raw) To: Jonathan Nieder; +Cc: git On Wed, Aug 06, 2008 at 04:22:00PM -0500, Jonathan Nieder wrote: > "git commit -a" ignores untracked files and follows all tracked > files, regardless of whether they are listed in .gitignore. So > don't use it to motivate gitignore. Makes sense to me. --b. > > Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu> > --- > I noticed this while reading through the git-scm book, which > looks very good. If I am missing something, I would be very > happy to know. Maybe the sort of person that wants to track the > exact contents of the working tree would prefer > "git commit -a -i ." over "git commit -a"? > > Documentation/user-manual.txt | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt > index 43f4e39..f421689 100644 > --- a/Documentation/user-manual.txt > +++ b/Documentation/user-manual.txt > @@ -1128,8 +1128,8 @@ This typically includes files generated by a build process or temporary > backup files made by your editor. Of course, 'not' tracking files with git > is just a matter of 'not' calling "`git-add`" on them. But it quickly becomes > annoying to have these untracked files lying around; e.g. they make > -"`git add .`" and "`git commit -a`" practically useless, and they keep > -showing up in the output of "`git status`". > +"`git add .`" practically useless, and they keep showing up in the output of > +"`git status`". > > You can tell git to ignore certain files by creating a file called .gitignore > in the top level of your working directory, with contents such as: > -- > 1.6.0.rc1.228.ge730 > > -- > To unsubscribe from this list: send the line "unsubscribe git" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2008-08-07 12:50 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-08-06 21:22 Documentation: user-manual: "git commit -a" doesn't motivate .gitignore Jonathan Nieder 2008-08-06 21:47 ` Miklos Vajna 2008-08-06 22:29 ` Jonathan Nieder 2008-08-06 22:54 ` Jonathan Nieder 2008-08-07 0:15 ` [PATCH] Documentation: clarify that git-commit only works with tracked files Jonathan Nieder 2008-08-07 0:39 ` Johannes Schindelin 2008-08-07 1:14 ` Jonathan Nieder 2008-08-07 11:00 ` Miklos Vajna 2008-08-07 11:52 ` Peter Krefting 2008-08-07 12:24 ` Documentation: user-manual: "git commit -a" doesn't motivate .gitignore J. Bruce Fields
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).