# Cloning or pushing only files that have been updated

2 messages from 2015-04-25 to 2015-04-25. Participants: cl@qgenuity.com, Johannes Sixt.
Thread: https://gitlist.dev/t/39160

## cl@qgenuity.com, 2015-04-25 21:17

Subject: Cloning or pushing only files that have been updated
Message-ID: <054116d47b69ca56f3369369df9fb4d8.squirrel@www.qgenuity.com>
URL: https://gitlist.dev/e/054116d47b69ca56f3369369df9fb4d8.squirrel%40www.qgenuity.com

```
Hi,

I have two sets of files.

A_Old is a large unversioned directory tree containing many files.

A_Updated is a git repository containing the files from A_Old, some of
which have been modified. A_Updated also contains new files.

I am looking for a way of cloning only the new or modified files from
A_Updated to A_Old. I would like A_Old to become a clone of A_Updated,
however I don't want to download the entire archive because of access
speed issues.

Timestamps on all files are accurate.

Any ideas?

- J

```

## Johannes Sixt, 2015-04-25 21:54

Subject: Re: Cloning or pushing only files that have been updated
Message-ID: <553C0D1C.2010301@kdbg.org>
URL: https://gitlist.dev/e/553C0D1C.2010301%40kdbg.org
In-Reply-To: <054116d47b69ca56f3369369df9fb4d8.squirrel@www.qgenuity.com>

```
Am 25.04.2015 um 23:17 schrieb cl@qgenuity.com:
> I have two sets of files.
>
> A_Old is a large unversioned directory tree containing many files.
>
> A_Updated is a git repository containing the files from A_Old, some of
> which have been modified. A_Updated also contains new files.
>
> I am looking for a way of cloning only the new or modified files from
> A_Updated to A_Old. I would like A_Old to become a clone of A_Updated,
> however I don't want to download the entire archive because of access
> speed issues.
>
> Timestamps on all files are accurate.

1. Create a commit from the files in each of the directories.

2. Use git rev-list --objects --all | sort to generate a sorted list of 
objects in each of the repositories.

3. In A_Old, generate a pack from the objects that are not in A_Updated 
using 'comm' of the objects lists piped into git pack-objects.

4. Transfer this pack from A_old to A_Updated.

5. Use git fast-export --no-data in A_old.

6. Use git fast-import in A_Updated to import the commit that you have 
in A_Old into A_Updated.

7. In A_Updated, git reset --soft the-commit-from-A_Old && git commit. 
Now you have a second commit with the updated state.

8. Use git-remote to connect the two repositories and to push or pull 
the updated state.

-- Hannes

```
