threads / discuss / 18425

How to commit changes if remote repository changed directory structure?

Subject: How to commit changes if remote repository changed directory structure?

## tl;dr

5 messages between Mar 20, 2009 and Mar 20, 2009.

replies: 4people: 4as markdown or json

andholt· Mar 20, 2009, 01:17 UTC · lore

I have a lot of local changes to add, commit, and push. Right now our directory structure is 1/2/3. Another developer decided to move everything up one level, so used git move to move 3 to 2, and removed 3, so now the level is 1/2. However, locally, all of my changes are in 1/2/3.

I want to commit my changes and merge them into the new directory structure. How would I go about doing that?

Thanks!
-- 
View this message in context: http://www.nabble.com/How-to-commit-changes-if-remote-repository-changed-directory-structure--tp22612715p22612715.html
Sent from the git mailing list archive at Nabble.com.
Jeff King· Mar 20, 2009, 06:09 UTC · re: andholt · lore

Re: How to commit changes if remote repository changed directory structure?

On Thu, Mar 19, 2009 at 06:17:15PM -0700, andholt wrote:
Show 7 quoted lines
> I have a lot of local changes to add, commit, and push. Right now our
> directory structure is 1/2/3. Another developer decided to move everything
> up one level, so used git move to move 3 to 2, and removed 3, so now the
> level is 1/2. However, locally, all of my changes are in 1/2/3. 
> 
> I want to commit my changes and merge them into the new directory structure.
> How would I go about doing that?
First, commit your changes. Then merge the other developer's changes. :)

This is exactly the sort of case that git's rename detection should handle; it should detect that the other side renamed files, and then consider your changes against the newly named files. The only thing it _won't_ handle is new files that you added in 1/2/3. You will have to manually move them to 1/2 as part of the merge (there has been discussion of "detect that this whole directory seems to have had its content moved and automatically move new files", but the patches have not been accepted).

-Peff
Junio C Hamano· Mar 20, 2009, 07:08 UTC · re: Jeff King · lore

Re: How to commit changes if remote repository changed directory structure?

Jeff King <peff@peff.net> writes:
Show 11 quoted lines
> On Thu, Mar 19, 2009 at 06:17:15PM -0700, andholt wrote:
>
>> I have a lot of local changes to add, commit, and push. Right now our
>> directory structure is 1/2/3. Another developer decided to move everything
>> up one level, so used git move to move 3 to 2, and removed 3, so now the
>> level is 1/2. However, locally, all of my changes are in 1/2/3. 
>> 
>> I want to commit my changes and merge them into the new directory structure.
>> How would I go about doing that?
>
> First, commit your changes. Then merge the other developer's changes. :)

We should probably point out to new people that "first commit and then worry about merges after your changes are safely committed" is always how people would "go about" anything.

Jeff King· Mar 20, 2009, 07:13 UTC · re: Junio C Hamano · lore

Re: How to commit changes if remote repository changed directory structure?

On Fri, Mar 20, 2009 at 12:08:51AM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> > First, commit your changes. Then merge the other developer's changes. :)
> 
> We should probably point out to new people that "first commit and then
> worry about merges after your changes are safely committed" is always how
> people would "go about" anything.
Yes, absolutely.

Most of the current documentation focuses on being a reference to particular commands or tasks. But this is more of a "philosophy of working with git" item. I guess it should go in the user manual somewhere. Cc'ing Bruce, who may have some comments.

-Peff
J. Bruce Fields· Mar 20, 2009, 22:30 UTC · re: Jeff King · lore

Re: How to commit changes if remote repository changed directory structure?

On Fri, Mar 20, 2009 at 03:13:19AM -0400, Jeff King wrote:
Show 14 quoted lines
> On Fri, Mar 20, 2009 at 12:08:51AM -0700, Junio C Hamano wrote:
> 
> > > First, commit your changes. Then merge the other developer's changes. :)
> > 
> > We should probably point out to new people that "first commit and then
> > worry about merges after your changes are safely committed" is always how
> > people would "go about" anything.
> 
> Yes, absolutely.
> 
> Most of the current documentation focuses on being a reference to
> particular commands or tasks. But this is more of a "philosophy of
> working with git" item. I guess it should go in the user manual
> somewhere. Cc'ing Bruce, who may have some comments.

I agree, that's kind of an odd hold in the user manual. Maybe it goes without saying, but it might be useful somewhere in ch. 3, maybe when introducing commits, something along the lines of: "note all of these commits are stored only in your local repository, and are visible only to you. With some version control systems, "committing" requires sending the commit to a central server. With git, you are expected to do all your work locally and only merge with others' work when necessary; we'll learn how to do that in <chapter 4>."

And then say something similar again at the start of chapter 4?
--b.

← back to recent threads