Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools GitHub Basics Working By Yourself Push Your Project to GitHub

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Setting up Github for cloning and pushing

I've been trying to work out what makes Git work, where the files live. One annoying thing is that some of the file paths weren't visible in Windows Explorer in the Windows environment.

I was able to locate the path to Git by opening the file location from the Git Shortcut and seeing the application in the AppData folder which isn't openly visible. Therefore I was able to copy the file path.

Path to Git: C:\Users\PC2\AppData\Local\GitHub

Another important file path was the ca-bundle CRT file. In the Git Powershell the path given on my system is this.

http.sslcainfo=/path/to/Git/mingw64/ssl/certs/ca-bundle.crt

I always assumed this was missing because error messages pointing to this path kept showign up when cloning and using git push .

I noticed that one of the directories was mingw64. I didn't have that. I only had mingw32. I didn't know if that would mean anything in terms of being able to set up cloning of repositories

But earlier on something weird and unexpected happened. I got an email in my associated GitHub email account telling me a new public key was added to my account.

I didn't have a clue how that happened, but earlier on I had opened the GitHub GUI application and had a poke a round. A cleaned out a couple of redundant repositories and scanned for the latest ones

As a test, I attempted to clone a remote repository on Github.

C:\path\to\repo> git clone http://github.com/username/repo.git
Cloning into 'ugliestcss'...
remote: Counting objects: 37, done.
remote: Compressing objects: 100% (26/26), done.
remote: Total 37 (delta 10), reused 36 (delta 9), pack-reused 0
Unpacking objects: 100% (37/37), done.
Checking connectivity... done.

I gasped with excitement I'd just successfully cloned a GitHub repository.

So I pressed on. If I've been able to get on to GitHub and fork a repository to my computer, surely I'll be able to put my local repository onto my remote. If I'm right, here I next needed to set up the local files to be pushed up to GitHub.

cd new_repo
C:\path\to\repo\new_repo [master]> git remote add origin https://g
ithub.com/jg-digital-media/new_repo.git
fatal: remote origin already exists.

Not exactly encouraging but I took a leap of faith. I think it's telling me that the files are ready to pushed to Github. A link to the remote repository as it were?

So I just tried the next step

C:\path\to\repo\new_repo [master]> git push origin master

And got the following response.

Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 787 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/jg-digital-media/new_repo.git
 * [new branch]      master -> master
C:\Users\PC2\Documents\GitHub\new_repo [master]>

And sure enough the repository, just a simple file at the moment is now up on Github.

So what was it that made it work? Opening the GUI application automatically sending an SSH key?

1 Answer

From the GitHub docs Generating an SSH key:

Tip: If you have GitHub for Windows installed, you can use it to clone repositories and not deal with SSH keys. It also comes with the Git Bash tool, which is the preferred way of running git commands on Windows.

So yes, I believe the GUI tool just does it for you. Note that GitHub is one tool for using the Git system, but they are not the same thing. So you will have Git installed on your PC, that GitHub for Windows uses to communicate with Git repositories on the GitHub servers.