- 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
vi .gitignore
- Configure username and e-mail address (unless already set globally from before)
git config user.name "Mona Lisa"
git config user.email "[email protected]"
- Optionally set username and e-mail globally for all your repositories
git config --global user.name "Mona Lisa"
git config --global user.email "[email protected]"
- When ready create the first commit
git add .
git commit -m 'Initial commit'
- Set 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 repository
git pull origin master --allow-unrelated-histories
-
If you have some merge conflicts resolve them and commit your changes
-
Push your changes
git push -u origin master