Wednesday, January 27, 2016

How to connect a non-empty directory into a git repository

  1. Open the Command Prompt (Windows)/Terminal (Linux)
  2. Go to folder location
  3. Type the following commands:

    git init
    git add -A .
    git remote add origin {url}
    git fetch
    git pull {url} master
    git commit -m "{message}"
    git push -u origin master
{url} is the location of your bare repository
{message} is any message that you want to identify the commit

Example:

I want to connect the c:\workspace\luizcgjr to the http://github.com/blogger/luizcgjr repository
  1. Open the Command Prompt (Windows)
  2. Type
  3. cd "c:\workspace\luizcgjr"
    git init
    git add -A .
    git remote add origin http://github.com/blogger/luizcgjr
    git fetch
    git pull http://github.com/blogger/luizcgjr master
    git commit -m "Added luizcgjr project to the repository"
    git push -u origin master
Source: http://stackoverflow.com/questions/3311774/how-to-convert-existing-non-empty-directory-into-a-git-working-directory-and-pus

No comments:

Post a Comment