Eclipse-fetch says my Git repo is current so what's the ↓13 mean? - eclipse

As a git noob, Eclipse is not helping my confusion... I switched to me local master branch and ran a fetch with the settings below:
Firstly I don't understand why the "Next" button is disabled. Secondly when I run the fetch using "Finish", it tells me I am already up to date (makes sense as I already fetched). So what does the ↓13 mean? Isn't it telling me my local branch is behind the remote branch? Or that the remote branch is itself behind... but this is the remote master so what can it be behind of?

It means that you are 13 commits behind the origin.
If the arrow is pointing up, that means that your branch is X commits ahead of the origin.
As far as your Next button being grayed out. I believe it's because you havn't selected the Ref yet. Click the ref, and then you should see it.
FYI - when i started out with Git, i tried to use the eGit plugin for Eclipse, and I can say to you as a new person in Git. Use command line! I've had my local git repositories corrupted from the plugins, and it's not very intuitive.

Related

How to view file changes before pulling through GitHub on RStudio?

I'm transitioning from using Subversion in Eclipse for code management to GitHub in RStudio. It's starting to make sense, but I can't seem to figure out how to pull effectively.
Specifically, if I use the Pull arrow in RStudio, every file change in the repository automatically updates my local files without warning. I can see how many files were updated, but not what changed!
Here are the questions I'm hoping to get help with:
1) Can I preview the repository file changes in RStudio before I pull them locally? With SVN in Eclipse, there was an indicator showing files with a difference, and the option to view side by side.
2) If multiple files have been changed on the repository, is it possible to pull just 1 locally?
3) How can I revert a local file to a previous version?
Right now I've been trying to do this all within RStudio for simplicity. I haven't used things like the GitHub desktop client.
I appreciate the help!
I would suggest you better get used to the git's own tools to stay informed about your repository.
For example you could do following.
Before you pull, check your current commit logs
git log
This should show you how your current commits stack up. Note the latest commit id (first 4-5 letters would usually do)
Now after pulling you can see the difference using following command
git diff --color your_previous_commit_id..HEAD
If you don't like the changes and want to go back,
you can just reset to your favorite commit with following command. BTW run "git stash save" to keep a copy of your uncommitted changes.
git reset --hard you_favorite_commit_id
Note: that this will delete all your uncommitted changes unless you stashed them and put your local branch behind the remote repo branch you are tracking again.
Wondering where to put these commands? Check https://git-scm.com/downloads.
What's good about using these git tools is that if you switch between IDEs you don't need to search for same functionalities you had in your earlier IDEs.

Eclipse, Egit, Github: remove pushed project folder

I have successfully created a git hub repository, a local master, committed the initial changes and pushed them to github.
Unfortunately the project folder from Eclipse ends up in the repository. For example:
<username>/<gitrepositoryname>/<eclipse project folder>/<project files & README>
when for most people it looks like:
<username>/<gitrepositoryname>/<project files & README>
I created a new local master after I found this tutorial Push eclipse project to GitHub with EGit
but now I am running into push problems such as "HEAD rejected - non-fast-forward" when using the new local master.
Can some please help me to correct this locally/remotely? Is there a way to switch local master branches so that I can sync the correct one with githib?
Thanks in advance.
It's pretty simple to fix:
Go to the "workspace" where you keep <eclipse project folder>
Make sure to delete the .git folder there
Tell git to force push the changes. (Checkbox) (It's usually not good to force git to do something, because you could loose commits/data BUT here, we really want to overwrite the old repository with the new one.)
Your changes should be up immediately. Next time you push, please make sure, the force push checkbox is disabled again

How do I get back my files marked as deleted in the unstaged changes area of Git staging?

I'm running Eclipse Kepler Service Release 1 with egit for versioning. I've been using eclipse and egit for just a few months and am not up on all of it's intricacies yet. I've found some related questions here for git, but I don't really understand how to use egit to accomplish what the answers propose.
The immediate problem I have is that no files are visible in the project tree except for the libraries and WEB-INF under war. The files show up in the unstaged changes area of the Git staging window marked with an x as deleted. This is a jsp project running google app engine if it matters.
What got me to this point was attempting to checkout the master branch. I got an error saying the branch could not find 2 files and afterwards my working files in the current branch disappeared. The Git repositories view shows my current branch is the same as the one I had been working on, so these files should normally be visible.
Since I never chose to delete these files I have no idea what stage egit thinks it's in. I don't have a backup and my other branches haven't had recent changes merged in.
You can always see the state of Git as a text decoration next to each repository node in the repositories view of the Git perspective. Normally that should only show the branch name, but it might also be something like "Interactive rebase", if Git stops for user input in the middle of an operation.
If that is not showing the branch name you want, then just the context menu Switch->[branchname] should bring you back to the wanted branch.
If everything else fails, you can always throw away all local changes and have your local working directory reset to the state of any commit (or branch) by using context menu->Reset->Hard and select the commit (or branch) to which you want to reset. Be aware that this wipes out any uncommitted local changes.
In case of more questions, you should read the very detailed EGit user guide.

EGit greying out / not showing commit

I've been running into a wired problem (which has been described (but not solved) here as well:
I used to develop using PyDev and Egit (recent versions, EGit is 3.0.3) with just a local repository. Everything worked fine, I was able to commit, branch, reverse etc. just using the "Team" menue in my PyDev perspective.
Now I added a remote reposisory to host the project and since then, I can not commit to my local repository. File changes are not detected (even worse: I change file A and afterwards all folders are marked as "changed" (having the ">" icon) and no file is recognized as "needing synchronization". The only menu points which are available are "Add to index" (which has no effect) and "Pull" (which says "everything is up to date" - which is true since there is nothing new on the server to pull).
When I use git (either command line or git extensions), I see the changed file as changed and it's offered for staging. I can use plain git to commit, push, etc, everything works as expected and no error messages are shown. I'm just using one branch (master).
Even if I open the "Git Repository Exploring" perspective in Eclipse and got to the tab "Git Staging", the file is listed.
I jus started a new test project with just a local repository (residing in the same git-folder ~/git) and here I can commit as I'm used to... And I added the project to the same repository server - and still everthing works! I can commit, I can push, everything is fine there...
yes, I can work around hat by using git extensions, but I really liked the smooth integraion of git in eclipse. Therefore, all ideas, remarks etc. are very welcome! And yes, I tried restarting eclipse ;o).
Finally!!!
Since everything was working before I added the remote host, amd everything worked in my small toy project, I removed and re-added my remote host using gut bash:
git remote remove origin
git remote add origin git#my_servername:my_repository.git
I suppose some configuration files were corrupted in a very non-obvious way (I checked all config fiels and did not notice anything...)
Sounds like a bug, and you might be able to get it back to a good state by playing around with the plugin setting data.
Located here: ${workspace}/.metadata/.plugins
I highly recommend backing up that whole folder before you start playing around. I have had other eclipse issues that have been resolved by going in here and deleting things.

Git reset gives me "still trying to merge"

I've googled this in many different ways and can't find anyone else talking about it (at least as far as I understand).
On my office pc I was trying to find a solution to a problem I was having (so I was ahead of my remote git repo, but without committing).
That night at home I figured out the solution and pushed it to my remote repo from my home pc.
Now I'm back in work and I wanted to reset my local repo on my office pc to match the remote (and discard all my local changes).
I ran:
git reset --hard origin/branch1
I got:
HEAD is now at 1501f25 **Still trying to merge**
What does this mean?
'Still trying to merge' seems to indicate it didn't complete somehow, but I can't see how (and I'm having no luck finding a clear answer in the git docs).
If a git merge --abort (git1.7.4+, January 2011) doesn't do it, check if you still have a .git/MERGE_HEAD file (and delete it).
Then the git reset should proceed (or, since it completed, the git repo state should be coherent).
Make sure you are in the right branch you wanted to reset to origin/branch1.
As the OP Roy Collings suggests, recloning should get rid of the warning, but that means having one's project config files versioned in order to minimize the time spent to configure everything again in a new cloned repo.
Since relative paths are supported in an Eclipse config, having .project and .classpath in a git repo is possible.