threads / discuss / 18123

How does Git know which files no longer needed during upgrade?

Subject: How does Git know which files no longer needed during upgrade?

## tl;dr

5 messages between Mar 3, 2009 and Mar 4, 2009.

replies: 4people: 4as markdown or json

dealmaker· Mar 3, 2009, 21:51 UTC · lore
Hi,
  I am going to upgrade software to a newer version in my main trunk, I
decide to download the newer version and checkout the main trunk and  copy
it over to my main trunk.  If the older version has some files that are no
longer in the newer version, how does git determine whether to keep those
files or not?  Does it even notify me that those files are no longer needed?
Thanks.
-- 
View this message in context: http://www.nabble.com/How-does-Git-know-which-files-no-longer-needed-during-upgrade--tp22318714p22318714.html
Sent from the git mailing list archive at Nabble.com.
Miklos Vajna· Mar 3, 2009, 23:30 UTC · re: dealmaker · lore

Re: How does Git know which files no longer needed during upgrade?

On Tue, Mar 03, 2009 at 01:51:14PM -0800, dealmaker <vinkhc@gmail.com> wrote:
>   I am going to upgrade software to a newer version in my main trunk, I
> decide to download the newer version and checkout the main trunk and  copy
> it over to my main trunk.

Do you mean the 'master' branch by 'main trunk'? Trunk is not in Git's terminology.

> If the older version has some files that are no
> longer in the newer version, how does git determine whether to keep those
> files or not?  Does it even notify me that those files are no longer needed?

First, I think storing upstream code (that you will never touch) in version control is a horrible idea, but if you really do it, I would do something like:

cd /path/to/copy rm -rf * cp -a /path/to/new/version/* . git add -A git commit -m 'update foo to 2.0'

That will add/update/delete files as you would expect.
Jeff King· Mar 4, 2009, 09:49 UTC · re: Miklos Vajna · lore

Re: How does Git know which files no longer needed during upgrade?

On Wed, Mar 04, 2009 at 12:30:58AM +0100, Miklos Vajna wrote:
Show 9 quoted lines
> First, I think storing upstream code (that you will never touch) in
> version control is a horrible idea, but if you really do it, I would do
> something like:
> 
> cd /path/to/copy
> rm -rf *
> cp -a /path/to/new/version/* .
> git add -A
> git commit -m 'update foo to 2.0'
Nit: "rm -rf *" will miss files starting with '.'. So it is probably
simpler to say what you mean: delete all files managed by git:
  git ls-files -z | xargs -0 rm -f
-Peff
Stefan Näwe· Mar 4, 2009, 12:28 UTC · re: Jeff King · lore

Re: How does Git know which files no longer needed during upgrade?

Jeff King <peff <at> peff.net> writes:
Show 13 quoted lines
> 
> > cd /path/to/copy
> > rm -rf *
> > cp -a /path/to/new/version/* .
> > git add -A
> > git commit -m 'update foo to 2.0'
> 
> Nit: "rm -rf *" will miss files starting with '.'. So it is probably
> simpler to say what you mean: delete all files managed by git:
> 
>   git ls-files -z | xargs -0 rm -f
> 
> -Peff
But maybe one wants to keep a .gitignore file. 

Regrads, Stefan

Jeff King· Mar 4, 2009, 12:38 UTC · re: Stefan Näwe · lore

Re: How does Git know which files no longer needed during upgrade?

On Wed, Mar 04, 2009 at 12:28:07PM +0000, Stefan Näwe wrote:
Show 12 quoted lines
> > > cd /path/to/copy
> > > rm -rf *
> > > cp -a /path/to/new/version/* .
> > > git add -A
> > > git commit -m 'update foo to 2.0'
> > 
> > Nit: "rm -rf *" will miss files starting with '.'. So it is probably
> > simpler to say what you mean: delete all files managed by git:
> > 
> >   git ls-files -z | xargs -0 rm -f
> 
> But maybe one wants to keep a .gitignore file. 

True. The problem is that you have no way of saying "give me all the files that git cares about, except the ones that I put there manually and not from this tarball." If you guess that dot-files are manual and everything else isn't, then that is easy, but not necessarily right.

If you tagged the last import, you use "git ls-tree" to get you the list of files just from the tarball.

-Peff

← back to recent threads