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

The Linux Filesystem

Docker introduction