{"thread":{"id":"9588","subject":"Git Questions","startedAt":"2007-08-20T09:55:48Z","lastAt":"2007-08-20T18:35:33Z","messageCount":9,"participants":["Tom Schinckel","Jeff King","David Kågedal","Andy Parkins","Matthieu Moy","David Tweed","Jan Hudec"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"51075","messageId":"1187603749.11595.10.camel@tom-desktop","threadId":"9588","inReplyTo":null,"subject":"Git Questions","fromName":"Tom Schinckel","fromEmail":"gunny01@gmail.com","sentAt":"2007-08-20T09:55:48Z","receivedAt":"2007-08-20T09:55:48Z","isPatch":false,"sender":{"key":"gunny01@gmail.com","avatar":null},"body":"Hi all,\n\nI've just started using git to run a repository on my local machine. I'm\nwondering about the following questions:\n\nIs it possible to change the revision numbers from long hashes to normal\nnumbers (i.e, 0001 for first, 0002 for the second)\n\nCan I set up Git to:\n\na) Automatically commit a file to the repository every time it's saved\n\nb) Automatically use the default hashed-out bit:\n\n\t# Please enter the commit message for your changes.\n\t# (Comment lines starting with '#' will not be included)\n\t# Updated but not checked in:\n\t#   (will commit)\n\t#\n\t#       modified:   TOK/bce.abw\n\t#\n\t# Untracked files:\n\t#   (use \"git add\" to add to commit)\n\t#\n\t#       TOK/bce.abw.bak~\n\nas the commit message? (i.e, remove the hash signs and not bring up vim\nin the first place?)\n\nThanks for any help.\n\ntom\n"},{"id":"51077","messageId":"20070820100600.GA26843@coredump.intra.peff.net","threadId":"9588","inReplyTo":"1187603749.11595.10.camel@tom-desktop","subject":"Re: Git Questions","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2007-08-20T10:06:00Z","receivedAt":"2007-08-20T10:06:00Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Aug 20, 2007 at 07:25:48PM +0930, Tom Schinckel wrote:\n\n> Is it possible to change the revision numbers from long hashes to normal\n> numbers (i.e, 0001 for first, 0002 for the second)\n\nNo, they are a fundamental part of the way git works. However, there are\na few ways you can avoid using the hashes:\n\n - tag your commits with readable names\n - use git's syntax for relative commits (e.g., \"git-show HEAD~20\") will\n   show you 20 commits back from the current commit (where back is\n   defined by following the first parent of each commit)\n\n> a) Automatically commit a file to the repository every time it's saved\n\nIf you want git to notice when files are changed and commit them, then\nno. You can probably configure your editor (or whatever is saving the\nfile) to trigger a 'git-add && git-commit'. But keep in mind this will\nproduce a lot of commits with lousy commit messages.\n\n> b) Automatically use the default hashed-out bit:\n\nThere isn't an argument to git-commit to do this, but you can get the\nsame message from git-status. So you could do something like:\n\ngit-status | sed 's/^# //' | git-commit -F -\n\n-Peff\n"},{"id":"51079","messageId":"87bqd2bgb0.fsf@morpheus.local","threadId":"9588","inReplyTo":"1187603749.11595.10.camel@tom-desktop","subject":"Re: Git Questions","fromName":"David Kågedal","fromEmail":"davidk@lysator.liu.se","sentAt":"2007-08-20T11:23:31Z","receivedAt":"2007-08-20T11:23:31Z","isPatch":false,"sender":{"key":"davidk@lysator.liu.se","avatar":"https://avatars.githubusercontent.com/u/60530?v=4"},"body":"Tom Schinckel <gunny01@gmail.com> writes:\n\n> Hi all,\n>\n> I've just started using git to run a repository on my local machine. I'm\n> wondering about the following questions:\n\nYou seem to have a very strange use case that you need to explain\nbetter.\n\n> Is it possible to change the revision numbers from long hashes to normal\n> numbers (i.e, 0001 for first, 0002 for the second)\n\nThere are no \"revision numbers\" in git.  There is only content.  The\nhistory of commits is created by having one commit point to its\n\"parent\" commit.  And in git, everything is addressed by its content,\nby using hashes.  So the long hash is a universal identifier for what\nit refers to.  It is not a revision number in your repository, it is\nsomething that can be used by someone else who hasn't even heard of yo\nto refer to exactly the same thing.\n\nSo, no you can't change that.  But there might be something else that\nyou can do if you explain what you're actually after?\n\n> Can I set up Git to:\n>\n> a) Automatically commit a file to the repository every time it's saved\n\nProbably, but remember that git doesn't track individual files.  It\ntracks the whole tree, so you would be creating a new revision of the\nwhole tree every time you saved that single file.  Which would not\ncreate a very nice history if you are using git for something it\nusually is used for (tracking source code etc).\n\n> b) Automatically use the default hashed-out bit:\n>\n> \t# Please enter the commit message for your changes.\n> \t# (Comment lines starting with '#' will not be included)\n> \t# Updated but not checked in:\n> \t#   (will commit)\n> \t#\n> \t#       modified:   TOK/bce.abw\n> \t#\n> \t# Untracked files:\n> \t#   (use \"git add\" to add to commit)\n> \t#\n> \t#       TOK/bce.abw.bak~\n>\n> as the commit message? (i.e, remove the hash signs and not bring up vim\n> in the first place?)\n\nWhy on earth would you want to do that?  That comment doesn't contain\nany information about what change you committed?  The list of files\nthat were modified by the commit is already in git.\n\n-- \nDavid Kågedal\n"},{"id":"51081","messageId":"1187612156.11595.17.camel@tom-desktop","threadId":"9588","inReplyTo":"87bqd2bgb0.fsf@morpheus.local","subject":"Re: Git Questions","fromName":"Tom Schinckel","fromEmail":"gunny01@gmail.com","sentAt":"2007-08-20T12:15:56Z","receivedAt":"2007-08-20T12:15:56Z","isPatch":false,"sender":{"key":"gunny01@gmail.com","avatar":null},"body":"On Mon, 2007-08-20 at 13:23 +0200, David Kågedal wrote:\n> Tom Schinckel <gunny01@gmail.com> writes:\n> \n> > Hi all,\n> >\n> > I've just started using git to run a repository on my local machine. I'm\n> > wondering about the following questions:\n> \n> You seem to have a very strange use case that you need to explain\n> better.\n\nWhat I'm using it for is to essentially create a history of various\ndocuments and other files that I'm creating. So if I accidently delete\nsomething or want to make a major change in the direction of an essay or\nthe like. \n\n(If anyone reads Linux Format, there was an article about a year ago\nabout \"Subverting your Home Directory\". I'm doing a similar thing, but\nwith git)\n\n> \n> > Is it possible to change the revision numbers from long hashes to normal\n> > numbers (i.e, 0001 for first, 0002 for the second)\n> \n> There are no \"revision numbers\" in git.  There is only content.  The\n> history of commits is created by having one commit point to its\n> \"parent\" commit.  And in git, everything is addressed by its content,\n> by using hashes.  So the long hash is a universal identifier for what\n> it refers to.  It is not a revision number in your repository, it is\n> something that can be used by someone else who hasn't even heard of yo\n> to refer to exactly the same thing.\n> \n> So, no you can't change that.  But there might be something else that\n> you can do if you explain what you're actually after?\n> \n\nGotcha.\n\n> > Can I set up Git to:\n> >\n> > a) Automatically commit a file to the repository every time it's saved\n> \n> Probably, but remember that git doesn't track individual files.  It\n> tracks the whole tree, so you would be creating a new revision of the\n> whole tree every time you saved that single file.  Which would not\n> create a very nice history if you are using git for something it\n> usually is used for (tracking source code etc).\n> \n> > b) Automatically use the default hashed-out bit:\n> >\n> > \t# Please enter the commit message for your changes.\n> > \t# (Comment lines starting with '#' will not be included)\n> > \t# Updated but not checked in:\n> > \t#   (will commit)\n> > \t#\n> > \t#       modified:   TOK/bce.abw\n> > \t#\n> > \t# Untracked files:\n> > \t#   (use \"git add\" to add to commit)\n> > \t#\n> > \t#       TOK/bce.abw.bak~\n> >\n> > as the commit message? (i.e, remove the hash signs and not bring up vim\n> > in the first place?)\n> \n> Why on earth would you want to do that?  That comment doesn't contain\n> any information about what change you committed?  The list of files\n> that were modified by the commit is already in git.\n\nThe reason I want to do that is so I can set up blind commits that I can\nadd in a anacron job or something. The information about the files isn't\nreally important\n\nThanks for the help: I'm using git in a uncoventional way. \n\ntom\n"},{"id":"51082","messageId":"200708201346.21557.andyparkins@gmail.com","threadId":"9588","inReplyTo":"1187612156.11595.17.camel@tom-desktop","subject":"Re: Git Questions","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2007-08-20T12:46:19Z","receivedAt":"2007-08-20T12:46:19Z","isPatch":false,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"On Monday 2007 August 20, Tom Schinckel wrote:\n\n> The reason I want to do that is so I can set up blind commits that I can\n> add in a anacron job or something. The information about the files isn't\n> really important\n\nThe point still stands though - what you are asking is to put information the \ncommit message that is available outside of the commit message anyway - so \nwhy bother?  If you really don't care about a commit message, then just use\n\n git commit -a -m \"\"\n\nThis commits all (-a) changed files and uses an empty commit message (-m \"\").\n\nThen later, if you wanted to see a summary of a particular commit\n\n git show --stat <commit hash>\n\nFor example, in my currently checked out git repository:\n\n$ git show --stat HEAD\ncommit 83b3df7d582429d9036f34d2c95abfff7bf0ab24\nAuthor: Junio C Hamano <gitster@pobox.com>\nDate:   Fri Jul 27 23:51:45 2007 -0700\n\n    git-stash apply --index: optimize postprocessing\n    \n    Originally, \"apply --index\" codepath was bolted on to the\n    \"update working tree files and index, but then revert the\n    changes we make to the index except for added files so that we\n    do not forget about them\" codepath, almost as an afterthought.\n    Because \"apply --index\" first prepares the final index state\n    upfront, \"revert except the added paths\" postprocessing does not\n    have to be done.\n    \n    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\n git-stash.sh |   13 +++++++------\n 1 files changed, 7 insertions(+), 6 deletions(-)\n\nIn particular note the summary at the bottom - that's not stored in the commit \nmessage, but git is perfectly capably of telling you all about what files \nchanged.  No need to put git-status in the log message as well.\n\n\n\nAndy\n-- \nDr Andy Parkins, M Eng (hons), MIET\nandyparkins@gmail.com\n"},{"id":"51083","messageId":"vpqlkc6nz8c.fsf@bauges.imag.fr","threadId":"9588","inReplyTo":"1187612156.11595.17.camel@tom-desktop","subject":"Re: Git Questions","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2007-08-20T12:53:55Z","receivedAt":"2007-08-20T12:53:55Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Tom Schinckel <gunny01@gmail.com> writes:\n\n> The reason I want to do that is so I can set up blind commits that I can\n> add in a anacron job or something. The information about the files isn't\n> really important\n>\n> Thanks for the help: I'm using git in a uncoventional way. \n\nOK. AAUI, you're abusing git as a backup system.\n\nThat's definitely not what git (and other VCS) is meant for. What git\nis good at is to create clean \"changesets\" (i.e. _you_ tell git when\nyou have something worth recording in history), and merging. But since\ngit is fast and disk-efficient (if you run git-gc from time to time),\nit can probably be a good backup tool too.\n\nIf you want to run \"git commit\" each time you save a file, you can\nprobably program your editor to do so, or use something like\nfam/inotify. But it's probably not reasonable, you'll quickly end-up\nwith thousands of file revisions (imagine the result if you run a\nscript like \"for i in $(whatever big thing); do echo $i >> file; done\").\nIf I were you, I'd set up a cron job to do the commit once every (few)\nminute(s). If the project is not too big, it will take less than a\nsecond, and commit will fail silently if you have no modification to\ncommit.\n\nYou'll want git to automatically add any new file, so you'll run\nsomething like\n\ngit add .\n\n# Remove deleted files.\n# There's probably a better way, but I don't find it.\ngit-ls-files --deleted -z | git-update-index --remove -z --stdin\n\ngit commit -m backup\n\n\nI don't think your idea of taking the output of git-status as a commit\nmessage is necessarily relevant: this information is anyway in the\ncommit, git-show and friends will show it. I'd say the commit message\nis irrelevant, and you can provide a dummy one. Otherwise, someone\nanswered in the thread.\n\n-- \nMatthieu\n"},{"id":"51084","messageId":"e1dab3980708200559v3f1def4ft85e31afb08394790@mail.gmail.com","threadId":"9588","inReplyTo":"200708201346.21557.andyparkins@gmail.com","subject":"Re: Git Questions","fromName":"David Tweed","fromEmail":"david.tweed@gmail.com","sentAt":"2007-08-20T12:59:41Z","receivedAt":"2007-08-20T12:59:41Z","isPatch":false,"sender":{"key":"david.tweed@gmail.com","avatar":null},"body":"> On Monday 2007 August 20, Tom Schinckel wrote:\n>\n> > The reason I want to do that is so I can set up blind commits that I can\n> > add in a anacron job or something. The information about the files isn't\n> > really important\n\nRegarding your basic intention, I've worked on something _similar_\nusing git and put it up on the web (although not got around to editing\nthe git wiki) at\n\nhttp://www.personal.rdg.ac.uk/~sis05dst/chronoversion.htm\n\n(with a minor update is going to go up when 1.5.3 gets released & I\ntest it works.) There are two important differences with what you want\nto do:\n\n1. As I recall someone else saying when talking about using SCM\non their home directory (Joey Hess?), if you blanket record\neverything you then end up being careful about, eg, piping a\ngrep search into a temporary file for some purpose, etc. So\nchronoversion takes a python function that decides if a file\nis \"worth recording\" (which can be by suffix or more general\nanalysis).\n\n2. As I've got a nervous tick of saving every couple of minutes\n(in case the editor or network I'm on dies), recording on save\nis too fine a granularity for me, so the script is designed to\nrun from a cron job (I have it at once an hour) and not make\na commit if it finds nothing has changed.\n\nAs I say, not exactly what you're looking for but it might be\nin the right direction.\n\n-- \ncheers, dave tweed__________________________\ndavid.tweed@gmail.com\nRm 124, School of Systems Engineering, University of Reading.\n\"we had no idea that when we added templates we were adding a Turing-\ncomplete compile-time language.\" -- C++ standardisation committee\n"},{"id":"51085","messageId":"e1dab3980708200606l4e26ce8bx45c31eee81f967af@mail.gmail.com","threadId":"9588","inReplyTo":"vpqlkc6nz8c.fsf@bauges.imag.fr","subject":"Re: Git Questions","fromName":"David Tweed","fromEmail":"david.tweed@gmail.com","sentAt":"2007-08-20T13:06:19Z","receivedAt":"2007-08-20T13:06:19Z","isPatch":false,"sender":{"key":"david.tweed@gmail.com","avatar":null},"body":"On 8/20/07, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:\n> OK. AAUI, you're abusing git as a backup system.\n\nJust as a point, I think a better word is \"archive system\". (Backups\nare more for replicating current state in the event of a system failure.\nClearly _if_ you're working on a well defined project, careful repository\nmanagement is a good idea. (One of the key things you lose\nfrom automatic commits is the ability to reliably bisect stuff.)\n\nHowever, not all the work one does on a computer is so\nfocussed and well-demarcated, so in other cases keeping\na history so you can, eg, look at what you're research codebase looked\nlike when you generated the results you pasted into a paper\non July 12 2005 is a useful ability, even if that sort of \"looseness\"\nwouldn't be appropriate in \"product\" based development.\n\nThe nice thing about git is that it's so efficient at the low levels\nit can be used for both \"proper\" SCM and archival storage.\n\n-- \ncheers, dave tweed__________________________\ndavid.tweed@gmail.com\nRm 124, School of Systems Engineering, University of Reading.\n\"we had no idea that when we added templates we were adding a Turing-\ncomplete compile-time language.\" -- C++ standardisation committee\n"},{"id":"51108","messageId":"20070820183533.GC8542@efreet.light.src","threadId":"9588","inReplyTo":"e1dab3980708200559v3f1def4ft85e31afb08394790@mail.gmail.com","subject":"Re: Git Questions","fromName":"Jan Hudec","fromEmail":"bulb@ucw.cz","sentAt":"2007-08-20T18:35:33Z","receivedAt":"2007-08-20T18:35:33Z","isPatch":false,"sender":{"key":"bulb@ucw.cz","avatar":null},"body":"On Mon, Aug 20, 2007 at 13:59:41 +0100, David Tweed wrote:\n> > On Monday 2007 August 20, Tom Schinckel wrote:\n> >\n> > > The reason I want to do that is so I can set up blind commits that I can\n> > > add in a anacron job or something. The information about the files isn't\n> > > really important\n> \n> Regarding your basic intention, I've worked on something _similar_\n> using git and put it up on the web (although not got around to editing\n> the git wiki) at\n> \n> http://www.personal.rdg.ac.uk/~sis05dst/chronoversion.htm\n> \n> (with a minor update is going to go up when 1.5.3 gets released & I\n> test it works.) There are two important differences with what you want\n> to do:\n> \n> 1. As I recall someone else saying when talking about using SCM\n> on their home directory (Joey Hess?), if you blanket record\n> everything you then end up being careful about, eg, piping a\n> grep search into a temporary file for some purpose, etc. So\n> chronoversion takes a python function that decides if a file\n> is \"worth recording\" (which can be by suffix or more general\n> analysis).\n> \n> 2. As I've got a nervous tick of saving every couple of minutes\n> (in case the editor or network I'm on dies), recording on save\n> is too fine a granularity for me, so the script is designed to\n> run from a cron job (I have it at once an hour) and not make\n> a commit if it finds nothing has changed.\n\nThere's inotify interface in recent Linux and there is an incron\n(http://inotify.aiken.cz/) tool to run action when a file changes. I didn't\nactually use that tool, but from description of the Debian package it looks\nlike it could be used to run git whenever you save something.\n\n> As I say, not exactly what you're looking for but it might be\n> in the right direction.\n\n-- \n\t\t\t\t\t\t Jan 'Bulb' Hudec <bulb@ucw.cz>\n"}]}