# Newbie "svn update" question

4 messages from 2009-12-01 to 2009-12-01. Participants: Mikko Oksalahti, Howard Miller, Tay Ray Chuan.
Thread: https://gitlist.dev/t/21805

## Mikko Oksalahti, 2009-12-01 09:25

Subject: Newbie "svn update" question
Message-ID: <loom.20091201T101313-496@post.gmane.org>
URL: https://gitlist.dev/e/loom.20091201T101313-496%40post.gmane.org

```
Hi,

I just started using git for my personal projects at home. Basic usage seems 
pretty straight-forward as well as setting up everything. However, I have a 
simple question about how do I mimic an "svn update" command on a locally 
created repository. Here's what I do:

some_existing_project_dir> git init
some_existing_project_dir> git add .

(about 1000 files added...)

some_existing_project_dir> git commit -a -m "initial commit"

(now I edit 10 files and accidentally delete some files that I'm not aware of)

How do I now get the accidentally deleted files back from the repository without 
losing local changes made to 10 files? 

I've tried using: "git checkout HEAD ." but my local changes after last commit 
will be lost.

I've tried using: "git pull ." but the deleted files are not restored.

So I'm looking for an "svn update" equivalent command that would semantically do 
this: "Get the latest version of all files from the repository and merge them 
with any local changes I've made to files."

I know a suitable command is available and I'm just a moron who can't read the 
manual correctly but help me out anyway :P

  Regards,
     Mikko

```

## Howard Miller, 2009-12-01 09:45

Subject: Re: Newbie "svn update" question
Message-ID: <26ae428a0912010145k61dbfc41l8243363493918445@mail.gmail.com>
URL: https://gitlist.dev/e/26ae428a0912010145k61dbfc41l8243363493918445%40mail.gmail.com
In-Reply-To: <loom.20091201T101313-496@post.gmane.org>

```
2009/12/1 Mikko Oksalahti <mikko@azila.fi>:
> Hi,
>
> I just started using git for my personal projects at home. Basic usage seems
> pretty straight-forward as well as setting up everything. However, I have a
> simple question about how do I mimic an "svn update" command on a locally
> created repository. Here's what I do:
>
> some_existing_project_dir> git init
> some_existing_project_dir> git add .
>
> (about 1000 files added...)
>
> some_existing_project_dir> git commit -a -m "initial commit"
>
> (now I edit 10 files and accidentally delete some files that I'm not aware of)
>
> How do I now get the accidentally deleted files back from the repository without
> losing local changes made to 10 files?
>
> I've tried using: "git checkout HEAD ." but my local changes after last commit
> will be lost.
>
> I've tried using: "git pull ." but the deleted files are not restored.
>
> So I'm looking for an "svn update" equivalent command that would semantically do
> this: "Get the latest version of all files from the repository and merge them
> with any local changes I've made to files."
>
> I know a suitable command is available and I'm just a moron who can't read the
> manual correctly but help me out anyway :P
>
>  Regards,
>     Mikko

'git status' should show you what files you have deleted.  'git
checkout filename' should get them back. I can't think of a way of
recovering every file you have just deleted although - I suspect it
might be tricky. Thinks like 'git pull' only apply to remote
repositories and you don't have one of those. You're not thinking of
it the right way (yet) :-)

Howard

```

## Tay Ray Chuan, 2009-12-01 09:49

Subject: Re: Newbie "svn update" question
Message-ID: <be6fef0d0912010149o5b5d0557xfb8c57e4a29e4d7e@mail.gmail.com>
URL: https://gitlist.dev/e/be6fef0d0912010149o5b5d0557xfb8c57e4a29e4d7e%40mail.gmail.com
In-Reply-To: <loom.20091201T101313-496@post.gmane.org>

```
Hi

On Tue, Dec 1, 2009 at 5:25 PM, Mikko Oksalahti <mikko@azila.fi> wrote:
> How do I now get the accidentally deleted files back from the repository without
> losing local changes made to 10 files?
>
> I've tried using: "git checkout HEAD ." but my local changes after last commit
> will be lost.
>
> I've tried using: "git pull ." but the deleted files are not restored.
>
> So I'm looking for an "svn update" equivalent command that would semantically do
> this: "Get the latest version of all files from the repository and merge them
> with any local changes I've made to files."

Are you looking for a command that

  "Restore deleted files, without reverting local changes",

or

  "Get the latest version of all files from the repository and merge
them with any local changes I've made to files."?

I would suggest adding the changed files, then doing a checkout.

  git add changed.file1
  git add changed.file2
  git add -p #alternatively, select hunks/changes to add interactively
  git checkout HEAD #although using . (current directory) should give
the same result

Note that your changes have only been added to the index, and you need
to commit them. The index/stage is a concept not in svn. See the user
manual for more on this.

I also suspect you are still thinking in svn mode when you said
getting the latest version from the repository. You already have a
repository locally. It is more an issue of syncing your local
repository with the one that you're following. Unlike svn, every time
you commit, your local repository is updated, not the remote one, and
vice-versa.

-- 
Cheers,
Ray Chuan

```

## Mikko Oksalahti, 2009-12-01 12:00

Subject: Re: Newbie
Message-ID: <loom.20091201T125555-549@post.gmane.org>
URL: https://gitlist.dev/e/loom.20091201T125555-549%40post.gmane.org
In-Reply-To: <26ae428a0912010145k61dbfc41l8243363493918445@mail.gmail.com>

```
Howard Miller <howardsmiller <at> googlemail.com> writes:

> 
> 2009/12/1 Mikko Oksalahti <mikko <at> azila.fi>:
> > How do I now get the accidentally deleted files back from the repository 
without
> > losing local changes made to 10 files?
> 
> 'git status' should show you what files you have deleted.  'git
> checkout filename' should get them back. I can't think of a way of
> recovering every file you have just deleted although - I suspect it
> might be tricky. Thinks like 'git pull' only apply to remote
> repositories and you don't have one of those. 
> 
> Howard
> 

Ok. That helps. I just assumed the 'git pull' would work same way on local and 
remote repositories but I guess not then...

> ....You're not thinking of it the right way (yet) 

I hate when you say that :P

  /Mikko

```
