git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [RFC] Removing deleted files after checkout

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Aug 23, 2005, 21:27 UTC
Message-ID
<Pine.LNX.4.63.0508231713450.23242@iabervon.org>
In-Reply-To
<20050823205052.GA13311@hpsvcnb.fc.hp.com>
On Tue, 23 Aug 2005, Carl Baldwin wrote:
Show 33 quoted lines
> On Tue, Aug 23, 2005 at 03:43:56PM -0400, Daniel Barkalow wrote:
> > On Tue, 23 Aug 2005, Carl Baldwin wrote:
> >
> > > Hello,
> > >
> > > I recently started using git to revision control the source for my
> > > web-page.  I wrote a post-update hook to checkout the files when I push
> > > to the 'live' repository.
> > >
> > > In this particular context I decided that it was important to me to remove
> > > deleted files after checking out the new HEAD.  I accomplished this by running
> > > git-ls-files before and after the checkout.
> > >
> > > Is there a better way?  Could there be some way built into git to easily
> > > find out what files dissappear when replacing the current index with one
> > > from a new tree?  Is there already?  The behavior of git should NOT
> > > change to delete these files but I would argue that some way should
> > > exist to query what files disappeared if removing them is desired.
> >
> > If you don't use -f, git-checkout-script removes deleted files. Using -f
> > tells it to ignore the old index, which means that it can't tell the
> > difference between removed files and files that weren't tracked at all.
>
> Maybe I'm doing something wrong.  This does not happen for me.
>
> I tried a simple test with git v0.99.4...
>
> cd
> mkdir test-git && cd test-git/
> echo testing | cg-init
> echo contents > file
> git-add-script file
> git-commit-script -m 'testing'
[point 1]
Show 6 quoted lines
> cd ..
> cg-clone test-git/.git/ test-git2
> cd test-git2
> cg-rm file
> git-commit-script -m 'testing'
> ls
> cg-push
> cd ../test-git
> git-checkout-script

Ah, okay. I think "push" and "checkout" don't play that well together; "push" changes the ref, which "checkout" uses to determine what it expects for the old contents, and then it's confused.

What you probably actually want is:

cd ../test-git git pull ../test-git2

which will correctly identify before and after, and remove any files that were removed.

Alternatively, you could do, at point 1:

cp .git/refs/master .git/refs/deployed git checkout deployed

Then, after the push and cd:

git checkout master cp .git/refs/master .git/refs/deployed git checkout deployed

because checkout does remove files if you switch from a branch with them (e.g., deployed) to one without them (master, after the push).

	-Daniel
*This .sig left intentionally blank*
Previous: Carl BaldwinNext: Carl Baldwin
Message 4 of 10 in “[RFC] Removing deleted files after checkout”
  1. Carl BaldwinAug 23, 2005
  2. Daniel BarkalowAug 23, 2005
  3. Carl BaldwinAug 23, 2005
  4. Daniel BarkalowAug 23, 2005
  5. Carl BaldwinAug 23, 2005
  6. Daniel BarkalowAug 23, 2005
  7. Junio C HamanoAug 23, 2005
  8. Carl BaldwinAug 23, 2005
  9. Daniel BarkalowAug 23, 2005
  10. Junio C HamanoAug 24, 2005

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.