Git initialise new repository with existing source

If you have an existing folder with code you want to push (commit) into a new fresh git repository you need to first create the repository in GitHub or Bitbucket.
You also need to have git installed on your local machine.

To start off in the directory you have your existing code project
git init

Connect to a remote repository
git remote add origin

Add files to the commit
git add .

Set the commit message
git commit -m 'Initialise repo'

Push files to the repo
git push origin master

Now the codebase is pushed into master branch in the git repo.

Photo credit: @synkevych


Popular posts from this blog

Rant: Don't name your mobile app with a pronoun prefix

Web 3.0: Component driven responsive design

Why you should use rem instead of px in webdesign