Git repository clone new or add to existing local project

GIT is an amazing code versioning tool. Well if you are new to GIT and wondering how to clone GIT repo locally to new folder or to the exising code folder.
Humm… Here are two methods, use according to your need.

Method1: Existing project

  • Step 1: Switch to your repository’s directory
    • cd /path/to/your/repo
  • Step 2: Connect your existing repository to Bitbucket
    • git remote add origin git@github.com:danyal14/someProject.git
    • git push -u origin master


Method2: Starting from scratch

  • git clonegit@github.com:danyal14/someProject.git
  • cd testecho "# My project's README" >> README.md
  • git add README.md
  • git commit -m "Initial commit"
  • git push -u origin master

Thats it and you are good to go.

 

About the author

Danyal Ali Butt

I'm working as programmer since 2002. Born, grew up, studied and worked in Pakistan now Im located in Denmark since 2006.

View all posts