Can I have git gui and git bash and eclipse git plugin looking at same repo simultaneously? - eclipse

I am using Eclipse to work on Android java projects on a Windows 7 machine. I am using Git to version-track, back up, and share.
I have git gui, git bash, and the eclipse git plug-in. My question really comes down to:
Is it safe and/or will my tools (gui, bash, eclipse) work right if I have them all open and looking at the same git repo at the same time?
I ask this because I have had eclipse fail to do a checkin a few times, and one time in git gui when it was barfing I got brave/stupid and hit the "unlock git index" choice. Since I did that unlock, none of my git clients have complained. But the suggestion that there IS a lock and that I "manually" unlocked it has me afraid that I have opened the door to non-thread safe crashes in my git repos.
TIA

Yes, it is safe. The index lock is something that is normally only intended to be held while an operation is in progress (e.g. while a commit is being created or a merge is being handled).
If you have to manually unlock the index it probably means one of your Git clients crashed/errored while it was doing one of those operations and thus accidentally left it locked.

Related

Clone huge 16 GB Git repo with Eclipse Neon

Is there any way I can clone a huge Git repository (16+ GB) using the Git integration of latest Eclipse Neon?
I'm cloning by HTTP connection.
First, I ran into timeouts, but then increased the Remote connection timeout to 1800 seconds in Eclipse config.
Then the cloning almost completed, but at the very end it always fails telling me Premature EOF.
I have increased the http.postBuffer to 524288000 also (as many users suggested on StackOverflow), but this was not much of a help.
I also tried cloning the master branch only, but again, I was stuck with the same error message.
Is EGit not capable of handling such a big repo over HTTP?
The only Git-related way to clone such a huge Git repo would be through the recent (February 2017) GVFS (Git Virtual File System).
As tweeted, for a 270GB repo:
“The Windows codebase has over 3.5M files. With GVFS (Git Virtual File System), cloning now takes a few minutes instead of 12+ hours.”
See github.com/Microsoft/GVFS.
GVFS is based on Git fork: github.com/Microsoft/git.
And based on a protocol whose specifications are described here.
This is not yet supported by EGit, or even regular Git for now.
Depending on what you want to do with the repo, a shallow clone may be the solution (it won't bring the full git history): https://www.perforce.com/blog/141218/git-beyond-basics-using-shallow-clones
also, for such big repo, consider using git lfs in the future: https://git-lfs.github.com/
finally, I've seen many huge git repos that became so big because had files that wasn't supposed to be saved on git (executable files, binaries, videos, audio, and so on). If by mistake something like that happen, you can remove it from history using filter-branch. Check this SO ans: How to remove/delete a large file from commit history in Git repository? or this github article https://help.github.com/articles/remove-sensitive-data/
EDIT:
Microsoft has been developing GVFS that may be a solution in a near future (i think it's still not ready, but I haven't tested)
Do you really have a code project that's 16GB? That's pretty crazy, man!
I think the least painful way to go about this, is to open your shell and just type git clone http://my-url/project.git. And then try to see if you can make the repository somewhat smaller.
Eventually, I ended up cloning the repository using a SSH connection.
This works fine, even from within Eclipse (using EGit).
I had to create a SSH key in Eclipse properties, since Putty's PPK format is not compatible with Eclipse. Then, I managed to clone the entire repository.
Seems like HTTP is not suited to download a chunk of 16+ GB. :)

Changing the git branch on eclipse

This is the first time I do this.
I imported a git project in eclipse.
Then I used the shell to create another branch and checkout to the new branch.
Is refreshing the imported project in Eclipse enough to tell Eclipse that we are working on the new created branch?
thanks
Right-click your project and select Team → Branch to create new branches or to switch between existing branches. You can also switch branches in the History view.
Actually, I don't think you even need to refresh the project. That is, assuming you have 'eGit' installed and your projects are already configure as git projects (they should be, because in most cases, egit does that automatically).
Whenever you run git commands on the shell (outside eclipse) egit will automatically refresh projects for you and update their status when you switch back to Eclipse.
If you are not using egit then yes, you have to refresh the projects manually, but that is all you'd have to do since running the 'git checkout my-branch' command in the shell already changed the files on disk to be those from 'my-branch'.
Actually when you are working with eclipse, eGit is a very cool tool integrated inside eclipse, which lets you do all git stuff, like
git checkout to a new branch
git create new branch
git stash
even view your unstaged changes(select files and avoid complexities caused by git add .)
and finally commit.
Read here to know more. Eclipse Egit user guide
So you get to do all version repository stuff at one place as you code.
So to answer your question, yes as you checkout a new branch even in a shell/command prompt your changes will be reflected in eclipse.

Can't commit with Github Windows, no reason given

I have been forced to use other apps, and the command line since Github for Windows is not allowing me to commit changes. I would like to understand what's the problem, but I simply get a prompt with this message:
Commit failed
Failed to create new commit
Then, it gives me the option of go to the Git Shell or to cancel. While I am not an expert with the terminal, I am able to make commits when I choose to go to the Git Shell (or to any other application for that matter).
I am using Github 2.0.5 on Windows 7.
After an exchange with the Github for Windows developers, the issue has something to do with Windows inability to work with paths when they're too long. The node_modules folders generated by Node.js is the culprit of this issue in my particular case.
However, the node_modules folders in my repository are gitignored. The fact that even when gitignored they create a problem in Github for Windows means the developers have to address the situation.
I expect a response or a patch from the developers soon. They have been very helpful. In the meantime, I am using SourceTree as my Windows Git GUI.

Is there a way to retrieve eclipse executed git commands?

I'm a regular git user, and I'm building some shortcuts in eclipse to activate some EGit functions.
I'm a bit wary of what is EGit doing (especially the synchronize workspace operations), and I was wondering if I could make EGit show what git commands it was using.
Do you know of an option to make it log to the console, or generally, how to find out which commands got executed?
EGit does not use the git executables. It reproduces, with the help of JGit, what the executables would do.
Git executables store the versioning state of a project in a number of files under the .git folder (branches, refs, commit objects, tags and so on).
EGit and JGit do the same.
For example:
A commit with git executables:
git commit -m "My commit message"
Would be executed in Java through EGit with CommitOperation.commit(), which uses JGit's CommitCommand.call(), which builds and inserts a commit object, which are representend through files.
There is no clear mapping between EGit's UI operations and their meaning as regular git commands, at least not to my knowledge.
One can go through (EGit, JGit, git)'s code and look for what is happening under the hood, though.
EDIT: a pgm package in JGit provides the inverse mapping: "Command-line interface Git commands implemented using JGit ("pgm" stands for program)"
EDIT: A not-merged Eclipse patch exists for logging what Egit does under the hood: https://git.eclipse.org/r/#/c/103342/
Please go to .git folder of your project. There will be a log folder like in my case (D:\Repo\GIT.git\logs)
all git command executed by eclipse are logged in respective branch file.
a sample of log is
0000000000000000000000000000000000000000 27f2e02544d389eb2412c1d467cc99f1786cd662 fanishshukla 1409137288 +0530 commit (initial): First Draft for Jboss
27f2e02544d389eb2412c1d467cc99f1786cd662 6d5634200cfdf6adf7c00ae70004326d2741e3a2 fanishshukla 1409557422 +0530 commit: fast response
6d5634200cfdf6adf7c00ae70004326d2741e3a2 32dbcfa55452b1a89861f422cfc7f90d26435d8c fanishshukla 1409557443 +0530 commit: fast response
What I found here:
There's a bug regarding this requirement:
Bug 349551 - Log EGit activities into a console
https://bugs.eclipse.org/bugs/show_bug.cgi?id=349551
How about git reflog to view command history of git

Auto commit and auto push changes in local repo to git

I have a local development system where I have a Ubuntu-Server VM and I use eclipse in windows host. I develop in eclipse using Remote System Explorer & SSH. I want that whenever I save a file or do some changes in ubuntu-server's /var/www/site-folder it automatically commits and pushes the changes in my git repo. I did try the google but it wasn't much of a help. Any help is appreciated guys. Really wanna improve my workflow.
This sounds like something you'll have to script. If you save as much as I do (a lot), then you'll end up with a lot of commits. Unless you're careful about when you save, you'll probably end up with a messy history, unless you squash things later.
Are you sure that you want to commit and push automatically every time you save? It also matters whether or not you're pushing to your own private branch or repo.
Actually I think there are use cases where this /is/ a good idea. If you work on two different machines (even not simultaneously), for instance, you cannot share the Eclipse workspace. One simple way to overcome this is to put a bare git repository on a cloud server (dropbox, copy, one drive, etc) and push all work, completed or otherwise, to that everytime you close eclipse.
Will the repo be messy? Sure, but that's not the point.
I could find no easy hooks within Eclipse itself to automate this so I simply put an invocation of Eclipse in a script and finished off with:
git commit -a -m "WIP commit"
git push origin
You just have to watch out for newly-created files and remember to add those before you exit.