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 trialDerek Markman
16,291 PointsQuestions installing git on android studio
I have just downloaded git and installed it, but the first question I have is when I type "git --version" inside of my windows powershell it shows that I have 1.9.5.github.0 installed and on my git bash window it shows that I have the latest version of git installed which is git version 2.5.3.windows.1
So which one of these is my actual git version? and since I have git installed, I went into my android studio vcs settings and linked my github account. Are there any plugins that I need to complete the setup?
5 Answers
Steve Hunter
57,712 PointsCreated a blank application called GitHubHelp. That was a challenge for some reason - odd Gradle issues as is so often the case!
Remember, I'm on a Mac so this may differ slightly for you. Anyway ... here goes:
I prefer to do this in the terminal. At the bottom of Android Studio, there's a terminal option. Select that. At the root of the project (it should open there) type git init
. Next type git add .
- the full stop adds everything; make sure it's there!
Then type git commit -m "Initial commit"
- that starts your local repository and populates it with code. We now want to get this to be remote too. Go to your Github home page and add a new repository - call it what you want and add some text in the 'about' field. You'll see mine in a minute ...
When you create the repository, the initial screen shows you a load of code. You'll recognise it as you've just done some of those steps. The next one you need to do is git remote add origin https://github.com/OnlySteveH/AndroidGit.git
which will be different for you - so copy that line from your screen into the terminal.
The the last line does the push: git push -u origin master
.
And you end up with a Github repo like this. Have a look about and you'll see the code.
Now, whenever you have worked on your code, commit the changes with a message git commit -m "What I just did to my code"
and you will have the ability to roll back those changes if they go wrong.
Hope that helps!
Steve.
Steve Hunter
57,712 PointsHi Derek,
Git and Github are two different things so they'll have different version numbers.
Git is the pipes beneath the porcelain that manages the version control, allows you to roll back, branch and collaborate. Github is one front-end that sits atop Git and makes that all much easier with GUIs and stuff. It also allows you to store your porjects in their cloud. Other frot-ends exist, like Bitbucket etc. They still sit on Git, though.
I hope that makes some sense! The Treehouse course on Git Basics is very useful, I must say.
If you have linked your GH account with AS, you can either create the repo on the Github webpage and follow the instrructions there, or you can try the AS options like 'Share project on Github'.
Over there, I'm OnlySteveH. Look me up!
Steve.
Derek Markman
16,291 PointsThanks for the fast answer Steve that makes a lot more sense to me. But don't I need to set a path to git executable? and also do I need to download any plugins for AS?
I actually did the courses here on git basics I just don't remember a whole lot(I should probably redo them to refresh on it all) and git/github is just a bit overwhelming to me, so I'm sorry for any noob questions I ask in the future lol.
Also do I need to set my system variable path for git?
Steve Hunter
57,712 PointsI don't think there's any plugin needed - AS comes fully integrated with Git.
The only path you might need is the URL to the remote repo once you've created it in Github. But you can do that from AS if you need to.
My view is just play with it - mess about and you'll get there in the end. I've got no formal knowledge of how to do much - I just keep pressing buttons and clicking the mouse and things happen!
Derek Markman
16,291 PointsI see lol sounds like my kind of method! But in order for you to use git did you need to set your git exec path in AS?
Steve Hunter
57,712 PointsI don't recall doing so, but then I use a Mac which comes with Git as standard.
Have a look about in Preferences - there's a separate section for Version Control. Yes, there's a path in there under the Git sub-section. Again, I'm on a Mac so it knows where that is! /usr/bin/git
So, you may need to do two setup pieces. First, the Git piece where you'll need a path. Then the GitHub piece where you need account name & password.
Derek Markman
16,291 PointsOk so inside my windows powershell I am able to use the git command and check my git --version etc.. but inside AS when I try to set my git exec path I can't seem to find my git file anywhere
Steve Hunter
57,712 PointsNo. Your Git path is nothing to do with GitHub.
It'll be something like: C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd
Every project has a .git
file - that's what it does, a file will be rooted in the root directory of the project so it can oversee changes made in that folder and deeper.
Derek Markman
16,291 PointsOk thanks I found my git.exe file but its located inside my programfiles directory not x86 is that still ok?
Steve Hunter
57,712 PointsThat's fine, yes. As long as the path leads to the right executable, it can live wherever it wants!
Steve Hunter
57,712 PointsIf that's where git.exe
is, then that's the right path, yes.
Derek Markman
16,291 PointsI also appended my git.exe path to the end of my system variable path. Now I just hope someone reply's to the thread for the app lessons that you were helping me out on yesterday.. I would really like to continue those lessons soon
Steve Hunter
57,712 PointsOK cool - so you now have a Git system set up and the ability to use Github as a front end.
Now, you need to get your project pushed up to Github so I can fork it and see if I can solve the issues here. Have you tried to push to Github?
I'm heading off on business for a couple of days so I'll not be as responsive as today, but it is on the lst of stuff to do over the hotel's wifi.
Derek Markman
16,291 PointsNo I haven't tried yet to push to github. I just have to import into version control > share project on github?
Steve Hunter
57,712 PointsYes, if you have a local git repo. Try it and chase the errors down.
You need to create a local Git repo. Then you initialize it and then add all the files to it. Then you can push to the remote repo.
Sounds complicated; it isn't, though.
Derek Markman
16,291 PointsAlright so I think I just initialized an empty repository under the name of Ribbit, so now all I have to do is push all my files into my empty repository?
Steve Hunter
57,712 PointsYep!
What's your Github name?
Derek Markman
16,291 Pointsmy github username is xD3R3Kx
Derek Markman
16,291 PointsSo can you see all my code did I do it right?
Steve Hunter
57,712 PointsYou're there; I'm following you but your repo is currently empty.
Derek Markman
16,291 PointsOk well when I get to the push commits on AS I have 2 options Ribbit & ribbit and both say empty repository, how do I push my code into my empty repository?
Steve Hunter
57,712 PointsStopped at Cambridge Services. Still nothing in your report that I can see.
Might be worth trying it manually from your project folder in Powershell.
Search the git help for:
Git init (I think you have done that) git add . Git commit -m "initial commit"
Then you add the remote and push it up using git remote push -u origin master, or something.
Alternatively, zip your project and email it to me. My Web page has my email address on it, and my phone number! So I'm not hard to get hold of - just check my profile stuff.
Steve.
Steve Hunter
57,712 PointsI'm a little behind, I think.
There's comment posted in my email that's not on here - and your repo has vanished! I'm around for an hour or so now, if you want to go through it.
Derek Markman
16,291 PointsYa sorry I keep deleting the repo because it didn't contain my app file just my 2 java files and that other one with the copyright and random xml files
Derek Markman
16,291 PointsI was gonna just try to redo it again after work tomorrow
Steve Hunter
57,712 PointsI wrote a response in this thread to help someone out with Github.
But that's in Xcode, not Android Studio. I'll do the same now with a new project in AS.
Derek Markman
16,291 PointsHey I just sent you an email but I think I got it to work check out the repo and let me know If it's missing any files.