-
First get to the existing directory
$ cd my/folder/
-
Now start a new git repository
$ git init
-
Identify if the current elements on the directory are needed or not and add them to the .gitignore file. When ready...
$ vim .gitignore
-
When ready create the first commit on the server
$ git add .;git commit -m'my first commit'
-
Now add the remote from where you want to clone
$ git remote add origin https|ssh:path/to/the/repository.git
-
Now just pull and merge with local git
$ git pull origin master
-
If you have some merge conflicts resolve them and commit your changes.
You are ready to go!
If your remote repository is NOT empty, you must do what Sochi pointed out here
You might want to add
--allow-unrelated-histories
flag in case the repo added as remote is not empty.This might be also needed if your repo is created with some preset files, e.g.,
README.md
or.gitignore
as first commit (GitHub now offers to do so when creating a repo). Details in https://git-scm.com/docs/git-merge#Documentation/git-merge.txt---allow-unrelated-historiesAnd perhaps include an optional step to push local changes to the remote:
Edit: forgot the most important part.. thanks for the list in a first place! :-)