Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save boocle/0ca26b562db6a027e6f54104c60bdb19 to your computer and use it in GitHub Desktop.
Save boocle/0ca26b562db6a027e6f54104c60bdb19 to your computer and use it in GitHub Desktop.
How to clone a git repo to an existing folder (not empty)
  1. First get to the existing directory
    $ cd my/folder/

  2. Now start a new git repository
    $ git init

  3. Identify if the current elements on the directory are needed or not and add them to the .gitignore file. When ready...
    $ vim .gitignore

  4. When ready create the first commit on the server
    $ git add .;git commit -m'my first commit'

  5. Now add the remote from where you want to clone
    $ git remote add origin https|ssh:path/to/the/repository.git

  6. Now just pull and merge with local git
    $ git pull origin master

  7. If you have some merge conflicts resolve them and commit your changes.

You are ready to go!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment