it:ad:git:howto:start_a_new_hosted_repo_for_visual_studio

IT:AD:Git:HowTo:Start a new hosted repo for Visual Studio

Summary

I don't have a thing against IT:AD:TFS – it's good enough technology, and excellent integration.

I have an issue against the long term OpEx side effects of TFS, namely:

  • Publicly visible code is no less secure than private code (in fact, study after study has demonstrated it to be more secure)
    • Performing in public leads to an inability to commit poor code, more responsibility, therefore better code.
  • TFS repos cannot be exported and re-imported, leading to vendor lockin for support contracts. This is absolutely suicide from a client's point of view.
  • Ensure you have IT:AD:SSH set up for your user/machine
    • YOu will need SSH for your command line interactions with Git over SSH
    • You will definitely need SSH on your dedicated Continuous Build/Continuous Deployment server.
  • Create a new Repository for your project

Let's get it working from the command line first

mkdir /path/to/your/project
cd /path/to/your/project
git init
git remote add origin git@bitbucket.org:<repoowner>/<reponame>.git

If you have SSH set up correctly, you'll be able to do the following from the command line:

echo "Test" >> _discardable.test.txt
git add _discardable.test.txt
git commit -m 'Commit test'
git push -u origin master

If you run into ssh troubles, the thought process should be:

  • cd %userprofile%/.ssh/
  • do you have an pub/private keys (specifically id_rsa)? if not, you'll need to:
  • ensure IT:AD:Chocolatey is installed
  • ensure git is installed (consider using choco install git -y)
  • ensure poshgit is installed (consider using choco install poshgit -y)
  • start/restart a new IT:AD:Powershell interface (in order to let IT:AD:PoshGit sink in correctly after installing it)
  • ensure %programfiles%/git/bin was/is added to the PATH (so that it can find IT:AD:SSH and IT:AD:SSH-ADD)
  • Check whether you have any certs (sounds like you don't have one):

ssh-add -l

  • Use ssh-keygen to create both a default id_rsa one, and one specific to you, on this machine, for bitbucket

$strFilePath="${Env:UserProfile}/.ssh/$fileName"
& "${Env:ProgramFiles(x86)}\git\bin\ssh-keygen" -f $strFilePath -t rsa -N "''"

  • Use ssh-add to ensure that the certs are registered with ssh-agent.

ssh-add <keyname>
#eg: ssh-add WE3W8-MEDIA_SkyS_bitbucket_rsa 

  • Create a %userprofile%/.ssh/config file in which you will tell git, when it invokes IT:AD:SSH, to look use the current target in the url (eg: bitbucket.org) to figure out which pub/private key to use, and which username to use. The config file looks like:

Host bitbucket.org
 User skysigal
 HostName bitbucket.org
 IdentityFile ~/.ssh/WE3W8-MEDIA_SkyS_bitbucket_rsa 

...other hosts (eg: github)

  • /home/skysigal/public_html/data/pages/it/ad/git/howto/start_a_new_hosted_repo_for_visual_studio.txt
  • Last modified: 2023/11/04 01:43
  • by 127.0.0.1