IT:AD:Git:HowTo:Crash Course
- See also:
- IT/AD/bitbucket/HowTo/Retarget A Repository From Git To Https Protocol
Summary
Devs just want to get going.
Process
Clone Existing work into a new Repo
- Before you can check in, the repo has to exist on IT:AD:BitBucket, IT:AD:GitHub, IT:AD:Visual Studio Team Services (VSTS) or wherever.
- Once the repo has an url:
# If you have nothing local yet, clone:
# BitBucket/Option A:
git clone git@bitbucket.org:<yourname>/<yourreponame>.git
# BitBucket/Option B:
git remote clone https://<youraccountname>@bitbucket.org/<nameofrepoowner>/<nameofrepo>.git
# CD to your project
cd <projectroot>
# ALTERNATIVE WAY:
# But sometimes you have an existing code folder, and don't want to create a new folder.
# In which case, create the local repo (ie, the `.git` folder):
git init
# Connect the local to remote repo:
#Bitbucket, Option A: SSH:
git remote add origin https://<youraccountname>@bitbucket.org/<nameofrepoowner>/<nameofrepo>.git
#Bitbucket, Option B: HTTPS (although you'll have to retarget afterwards):
git remote add origin git@bitbucket.org:<yourname>/<yourreponame>.git
# Can't push up the cloud repo till there have been some changes. So make a file:
echo NULL > readme.md`
# Still can't push up to the cloud until you've Committed the changes:
git add contributors.txt
git add .
# Commit:
git commit -m "Initial commit with contributors"
# Push:
git push -u origin master