I really wanted to avoid this, but I am starting to realize that the best way to code and remember what I'm coding (along with configurations and all) is through writing down my experiences and listing my references. Blah, wish I could skip all this and just load everything into my fat brain like in the Matrix. Anywho...learning the new kung-fu (i.e. coding) - begins.
Assignment: Create a simple Java application and push up into my GitHub repo.
- I already have a GitHub account. https://github.com/gradney
- I had to reset the password because I haven't used this since July 2013. Sucks to have to start all over.
- Login to GitHub is now successful. I didn't like the duplicate "menbuild" in the online path for MenBuild repo (i.e. https://github.com/gradney/menbuild/menbuild) and deleted this repository. I want this path to look like https://github.com/gradney/menbuild.
- To delete GitHub repo, see @ https://help.github.com/articles/deleting-a-repository
- In starting all over, I decided to redo the simple GitHub tutorial for starters.
- See my results @ https://github.com/gradney/Hello-World
- What is Markdown (md)? See more @ http://bywordapp.com/markdown/syntax.html
- Next, I opened my Eclipse which I had already connected my Git-specific workspace to GitHub and noticed I still had some old stuff. Since I already deleted the "menbuild" repo, I deleted repo (with its contents) from my Eclipse AFTER I copied any useful files to my Desktop. I was left with the "tester" repo. I'll get to this later.
- I started running into a lot of issues with trying to use my existing Eclipse workspace (pointing to C:/User/gradney/git) and pushing projects up to my GitHub. Strangely, I didn't run into issues fetching projects down from my GitHub. Anyhow, tired of being constipated (i.e. running into *push* issues).
- I decided that I'm deleting my entire workspace and starting all over with Eclipse. One thing I now realized is what may be significant in keeping Eclipse metadata files separate from Git metadata files. What I had done was make my Git folder also the same as my Eclipse workspace (both pointing to C:/User/gradney/git). From reading the following online article, I'll empty my "git" folder and keep my Git default repository pointing here. On the other hand, I'll create a new workspace specifically for Git projects in Eclipse pointing to C:/User/gradney/workspace/Git.
- Using Eclipse with Git, see @ http://www.vogella.com/tutorials/EclipseGit/article.html
- Now that I'm starting with a fresh setup with Eclipse (including Git plug-in), I will skip adding the .gitignore file for now. I prefer to keep these files within each Git project because I'm sure there will be specifics later on (according to project's purpose and coding language used) and because I would like to upload this file into GitHub for others to know clearly what all is included in my specific Git projects. In my opinion, anyone who would like to use my projects should be able to fork/fetch my projects (sorry, still learning the lingo of Git world) and run on their local machine w/out any issues.
- Let's get to the point of this: Creating a Java project to store in GitHub.
- Create a quick Java Project. I'm calling mine "Hello-Java". This will be similar to "Hello-World" done through the GitHub starter tutorial, but this is specific to Java using Eclipse.
- How am I doing this? I open the Java Perspective in Eclipse, add a Java Project, create the source files, compile and ensure everything works in Eclipse. (That is, I can run my program in Eclipse.)
- Once I finish running my program successfully, I open the Navigator View (since Java Perspective typically opens the Package Explorer). In the Navigator View, I can see all my files in this Hello-Java Project. Here is where I'll want to add my .gitignore file mentioned by Vogella (in link above). I want my .gitignore file to be specific to this Java project. I add this .gitignore file in the Hello-Java folder (not the "bin" folder, not the "src" folder, etc.). It's okay if my other .* files are uploaded like the .classpath because this will help others know what might have also been used to compile my project (like for more complex projects I may use Apache libraries, etc.).
- I go back to my tutorial by Vogella and follow through with adding my project my GitHub via Git. I configure my Git Repository as "C:/Users/gradney/git/Java/.git", my Working Directory as "C:/Users/gradney/git/Java". So, I see my Project checked as "Hello-Java", my Current Location as "C:/Users/gradney/workspace/Git/Hello-Java", and my Target Location as "C:/Users/gradney/git/Java/Hello-Java". I click Finish and let's see what happens.
- Interesting, I see Eclipse added "[Java NO-HEAD]" to my Hello-Java project in the Navigator View. When I go to my git folder via Windows Explorer, I see a Java folder with a ".git" subfolder and a "Hello-Java" subfolder (with my program). When I go back to my project in Eclipse and right-click on my Hello-Java project and go to Team, I see a bunch of Git commands now. Cool! But wait, I don't see my Hello-Java project in my Eclipse Workspace via Windows Explorer. This is quite strange. Let's continue to see what happens.
- Oh no, I just realized something. Maybe my idea of where to place the ".gitignore" file needs to be in the parent folder of the project in git? So, I'll copy my ".gitignore" file from the "Hello-Java" project into the git root folder (C:/Users/gradney/git) and add one line to ignore the RemoteFiles directories.
- I continued with seeing the Staging view in Eclipse from Vogella's tutorial, but I'm getting anxious to see how to push my local repository to GitHub. So, I moved forward with going to my "Git Repository Exploring" Perspective, right-clicking on Java repo, selected "Push", ....wait let me keep reading through Vogella's tutorial. Oh shit! I can't create a repo INTO GitHub. I always have to create my repo in GitHub first, and then I can add projects to it.
- Let's try again later...
- Ok, going through Vogella's Tutorial again - using EGit with GitHub (section 21).
- As you can see, I wasted a lot of time already. This sucks! But, I did learn something.
- Delete my repository in Eclipse via the Git Repository Explorer. Include deleting from workspace, etc. Check via Windows Explorer that the folders and files are deleted. Checked (and .gitignore file is still in my root git folder).
- Following through with Vogella's tutorial and creating a Git Repo on GitHub called "Java".
- I copy the HTTPS URL from GitHub to add into Eclipse.
- Currently, there are no existing projects in Java Repo, but we'll continue without any projects by saying "next" that we want to import all the existing (zero) projects. Or, we'll just cancel.
- Ok, this is not helping.
- In Eclipse, go to Git Repository Exploring and add a repository by selecting "Clone a Git repository".
- URI: https://github.com/gradney/Java.git
- Host: github.com
- Repository Path: /gradney/Java.git
- Protocol: https
- User: <myUsername>
- Password: <myPassword>
- When asked about my Local Destination, I have:
- Directory: C:\Users\gradney\git\Java
- Remote Name: origin
- everything else is blank.
- Click Finish.
- Alright, we have a Git Repo from GitHub. Now, to figure out how to add my project in Eclipse to this repo.
- Create a new Java Project.
- Once created, right-click and select Team > Share Project...
- Select "Git", click Next.
- Select Repository: Java - C:\Users\gradney\git\Java\.git
- Leave Working Directory as C:\Users\gradney\git\Java
- This is our local Git repository (claimed as our Working Directory).
- The following should be stated in the dialog "Configure Git Repository"
- Project: Hello-Java
- Current Location: C:/Users/gradney/workspace/Git/Hello-Java
- Target Location: C:/Users/gradney/git/Java/Hello-Java
- Click Finish.
- Right-click on Hello-Java project, select Team, select Commit...
- Add message into Commit Message, select the Files to commit, and click Commit and Push...
- Ok, got an error regarding I'm not authorized.
- Let's see, this time I followed through with GitHub's instructions on "Create a new repository on the command line".
- I click on my Java repository link in GitHub, and now I see a blank README.md file in my repository. Ok, so my commandline to GitHub is working. But, what about my Java Project to GitHub???
- Ok, I'm still getting errors. This just doesn't make sense.
- After doing some more searching over the Internet, I found this article @ http://stackoverflow.com/questions/14259265/egit-not-authorized
- In the instructions, I would add this clarity:
- A. To specify credentials individually for each remote
- Open Git Repository Exploring perspective.
- Open Git Repositories view.
- Expand the git repository. In my case, I had to expand Java [master] repo.
- You should see a 'subfolder' (for lack of better word) for Branch, Tags, References, Remotes, and Working Directory.
- Expand Remotes subfolder (and see 'origin').
- Expand 'origin'.
- Right-click on fetching the git repository and select "Change Credentials...".
- In the dialog, ensure the Repository is pointing to the desired one (in my case it is "https://github.com/gradney/Java.git") and enter your correct username and password. Click OK.
- Do the same for pushing to git repository (by right-clicking on pushing to git repository under 'origin', selecting "Change Credentials..." and entering correct credentials).
- Ok, now that we finally resolved the issue with connecting EGit to GitHub, let's see if we can finally create a Java Project and push to my GitHub Java Repo.
- In Eclipse, go to Java perspective and create the quick Hello-Java project with a HelloJava class. Make sure it runs without errors.
- Once created, right-click and select Team > Share Project...
- Select "Git", click Next.
- This view is already so much better. My dialog titled "Configure Git Repository" does NOT show the local and destination crap from earlier. Instead, simply has "Use or create repository in parent folder of project" checked, and only the view with the Project, Location, and Repository:
- Project: Hello-Java
- Location: C:\Users\gradney\workspace\Git\Hello-Java
- Repository: ..\..\..\.git
- I simply click "Finish".
- I see Eclipse is "re-indexing repository gradney" in the lower right corner of my Eclipse screen while the bar is loading. This looks like a good sign.
- Waiting for indexing to complete...
- Yes, seems to have worked!!! In my Package Explorer (in Eclipse's Java perspective), I finally see the question mark (?) next to my Java project files. This means, in git, that I have new/updated files which are not yet committed and pushed to my repo.
- However, when I'm trying to stage my project, I'm running into Java Heap Exceptions in my Eclipse (and my Eclipse is locking up). I decided to add my ".gitignore" file into the Hello-Java project. Eclipse is currently re-indexing.
- Ok, so my Eclipse keeps running out of memory because it's trying to stage everything with my one Java project. What a drag! I closed my Eclipse. Well, I added a global .gitignore file into my user folder. I added what Vogella mentions in his article.
- Location of my global .gitignore file @ C:/Users/gradney/.gitignore
- I open my Eclipse and let's see what happens. The Git Staging view has disappeared. Maybe that's a good thing. Let's see if we can right-click on our Java project and commit.
- Nope, still running into issues. Ok, this is just too much. Tomorrow, let's just use another Git client, and only use Eclipse for Java projects. How disappointing. I'm very disappointed with EGit. Not sure what happened from last summer until now. Last summer it was working great. Now, it's garbage.
- Or maybe this has something to do with my work machine.
I almost forgot to say some important specs (i.e. specifications). Here's the software I'm using:
- My operating system is - Windows 7
- Java 7 - jdk1.7.0_21
- IDE, not sure of the version, but using - Eclipse IDE Juno
- don't forget the Git plugin
- Git version 1.8.1.msysgit.1
- PSPad (my favorite text editor)
No comments:
Post a Comment