Using default git-commands are easy enough (if you are used to it), but this month I have started up two new projects on a clean computer. Setting up git for the first time is not a big issue, but I always start Googling – so this is a simple “from scratch” guide for starting with git on a clean Windows-computer and a new repository (on BitBucket).
1. Download git
2. Create a new repository.
Open browser and go to BitBucket, click the + icon and select Repository.
3. Open git bash
Open Explorer. Navigate to you project folder. Right click inside the folder and click “Git Bash Here“.
4. Generate SSH keys
Write “ssh-keygen -t rsa” in the git bash.
It will suggest a default path, usually C:\Users\Username\.ssh\, so just push enter here. You will be asked for a passphrase. I recommend setting one, but you don’t have to.
5. Copy your public key.
Navigate to the ssh key path and open id_rsa.pub in notepad.
6. Add public key to BitBucket.
Open the browser and BitBucket-page again. Go to settings for your userprofile. Open “SSH keys” in the settings-navigation. Click “Add key”. Give it a name and paste the content from id_rsa.pub.
7. Add a gitignore-file.
Open notepad and save the file as “.gitignore” under your project folder.
Write come content that you don’t wan’t to push in your git repository. Usually create a new config-sample.php file without your password.
Content in the file can be something like (* = wildcard):
8. Init, commit and push your code
Open the git bash. Write:
git add .
git commit -m “First commit”
git push -u origin master