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 git@bitbucket.org:username/reponame.git

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


Comments

Popular posts from this blog

Why you should use rem instead of px in webdesign

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