Here are some quick guidelines to get up and running with Github quickly.
This article assumes you are on Windows and use Visual Studio for coding, but it could very well be another OS or IDE.
Create an account first at Github.
Create a new repository.
Download and install Git here and install according to this guidelines.
Now, rightclick on your Visual Studio project folder and choose 'Git Bash here'. We are going to generate SSH keys first.
Type:
$ ssh-keygen –C 'barbarabarend@gmail.com’ –t rsa”
Accept all the defaults and don't enter a passphrase.
now type:
$ cd ~/.ssh $ vim id_rsa.pub
now copy all the contents of this file and paste it in the Github website under Account:
Now, navigate to your Visual Studio project folder. And type:
$ git config --global user.name "Barbara Barend" $ git config --global user.email barbarabarend@gmail.com
Or whatever your name is.
$ git init $ touch README $ git add README $ git commit -m 'first commit' $ git remote add MyRemoteRepo git@github.com:YOURGITHUBNAME/test.git $ git push MyRemoteRepo master
Line 5 is one line!
Now the Readme file is placed in your Github repository.
So, at this point you verified that you can actually upload your codefiles to Github and it's time to upload the whole project. But you probably want to ignore a few files and folders (e.g debug and bin and so on).
To exclude files from being posted to Github, you need to create a .gitignore file. Like this:
$ touch .gitignore
Now, edit this file with your favorite text editor and make it look like this:
obj bin *.csproj.user *.suo *.cache Thumbs.db # Other useful stuff *.bak *.cache *.log *.swp *.user mysecrettextfile.txt passwords.txt
Just basically add what you don't want to be included. Upload the .gitignore as well:
$ git add .gitignore $ git commit -m 'my ignored files' $ git push MyRemoteRepo master
Okay, now push your Visual Studio Solution to Github:
$ git add . $ git commit -m 'the whole she-bang' $ git push MyRemoteRepo master
Now what if you want to add existing code? Like the fabulous ShoeShoe app as discussed in the former blogpost?
Create a new folder for these files and start the Git bash.
$ git init $ git remote add MyRemoteShoeRepo git@github.com:YOURGITHUBNAME/MyShoeShoes.git $ git clone git@github.com:YOURGITHUBNAME/MyShoeShoes.git
So this was quick and dirty, but it does the trick.
One thought on “Github quickstart”