EGit automatically add new files - eclipse

When executing a commit of a set of files within the EGit eclipse plugin, I always have to add new files manually in the commit dialog
Is there a way to configure the plugin in a way, that adding new files automatically is the default setting?

Such an option exists now, it can be enabled in the preferences in Team → Git → Commit Dialog by checking Include selected untracked files:
Note that only untracked files that are contained in the selected files/folders/projects are included – so it depends on where you opened the context menu from.

Right now, there doesn't seem to be any option to have all new files added automatically.
(and this wouldn't be possible as well with Git)
Even on the commit stage, Git proposes only git commit -a -m "..." in order to automatically stage files that have been modified and deleted, but new files you have not told git about are not affected.
In other word, this would be a new feature in EGit which wouldn't have any direct correspondence in Git.

Related

How to ignore a file already committed on GIT repository in Eclipse using EGit?

I try to ignore a committed ".project" file on Eclipse EGit, without deleting it from my Eclipse project nor the repo.
I have this need :
the ".project" file of my Eclipse project must be committed at least
at the begining of the project, so that my co-workers can pull it
when they will "build" their Eclipse workplace
this file could be modified by any of us, but should not be pushed on GIT repo
this file must stay on GIT repo all the time, because a co-worker could have to get back the project at any time
we are working on Windows, so using command-line is a bit off-subject : I seek for help on Eclipse EGit
We are migrating from SVN to GIT : on SVN, we did not had this kind of problem, because we could not commit some files. On GIT, it seems that we have to commit everything we modify so that we do not have conflicts.
Can anybody help me ?
Thank you !
Right-click the file and choose Team > Advanced > Assume Unchanged.
See Eclipse Help - EGit Documentation - EGit User Guide - Reference:
Resources can be flagged "assume unchanged". This means that Git stops
checking the working tree files for possible modifications, so you
need to manually unset the bit to tell Git when you change the working
tree file. This setting can be switched on with the menu action
Team > Assume unchanged and switched back with the menu action Team > No Assume unchanged.
It should be noted that each co-worker must do this once. A server-side Git hook could reject commits changing .project if a co-worker had forgotten to do so.

Are gitignore files being automatically created in my project?

I have been trying to manage the local copy of the project I am working on using EGit.
I make a pull once there is a push from the other guys. However, there are files that show that I have uncommitted changes in my local repository, but I haven't made any change. I try to resolve these by manually identifying these changes and discover that they are from gitignore files, which I didn't create myself (the files also show errors occasionally).
Is it possible that the gitignore files are being auto-created? How can I maintain a synced local repo state? I am using Eclipse Kepler.
It is possible that the settings "Automatically ignore derived resources" triggers the generation/modification of .gitignore.
This is a consequence of bug 297674, adding that feature in EGit 2.3 (Q2 2013).
See the EGit tutorial:
You can also configure Eclipse to automatically ignore derived resources, e.g. class files via the Window → Preferences → Team → Git → Projects → Automatically ignore derived resources .. setting.

How do I configure Eclipse to use an existing git repository with existing source code?

I have Eclipse Juno with EGit and a project that I've been working on for a while. I've decided to move it to Git, so I created a Github account and downloaded and installed the program. The repository is at C:\Users\username\GitHub\project_name\, but all it has is the README.md file.
How can I configure Eclipse to use my existing source code (in a workspace separate from the git folder) to work well with git? I've tried using Window → Show View → Other and selecting "Git Repositories," but other than adding a repository (which I have done) I can't figure out how to sync the code.
I've read this question but I get the impression that those answers will perform a one-time commit, instead of a sync.
To clarify: The repository does not have any code. I would like my existing code (in the Eclipse workspace) to be synced to the new repository.
If you already have a git repository in place, first copy all your files to that directory (yes, manually) and do a git commit -a to commit all the files into the repository. I'm assuming here that you've already initialized the repository at C:\Users\username\GitHub\project_name\ with git init.
In eclipse, go to File → Switch Workspace → Other... and point it to a workspace of your choice that can be completely different than the location of your code, or your earlier workspace. In fact, don't point it to the directory which contains your git repository.
Once you have a clean workspace, go to File → New → Other..., select Git → Git Repository and enter the path of your git repository (C:\Users\username\GitHub\project_name\). Enter a name for the repository, and click Finish.
I would really recommend you read at least the first few chapters of the git book to understand how git works, and to help you push and pull code to and from remote repositories.
If your existing repository is not git, you're going to have a hard time keeping the directories in sync. You might want to setup rsync to sync the directories. There is no way AFAIK for eclipse to automagically keep the two repositories in sync.

Github and Eclipse: not all files are commited

I´m using Github in Eclipse, and commiting my changes to it. I have added some files to my project, and I have clicked on Team->"Add to index" in each of them, for them to be commited when I make a commit of the whole project. However, these files are not added to be commited, and when I click in "Commit", they arent´shown in the list of modified files. How can I force them to be commited?
Thanks.
It sounds like you may be confusing the usage of Git wit SVN. In SVN when you add a file to be tracked, updates to the file will always be committed automatically.
In Git, when you add a file to the index, only the current version of that file is recorded. If you subsequently update the file and commit, the new updates won't be included. The solution is to do an "Add to index" on the root of your project right before you commit: the equivalent of git add . on the commandline. Make sure your .gitignore is set up correctly so you don't commit things you don't intend to.
An equivalent action is to do a git commit -a, which automatically adds all files previously in the index and updates any deleted files as well. I believe the equivalent setting in Eclipse (for eGit) would be to Include selected untracked files as in the commit settings below.

Eclipse: how to remove a directory tree from a CVS repository?

The project I am developing with Eclipse is under CVS version control and I have successfully used the "Team -> Add to Version Control" function to add an entire directory tree into the repository. However, there seems to be no way in Eclipse to remove files from the repository... is that true? The "Team" tab does not include any remove function and simply deleting files does not remove them from CVS.
I know how to remove files and folders from a CVS repository using cvs remove on the command-line, but it would be just so convenient to have Eclipse do all the recursive deleting for me...
In Eclipse just use the regular Delete functionality; when you synchronize or commit to your repo, the file(s) you've deleted will be removed. Like most cvs actions, it's a multi-step process: you make the change locally and then commit it to the repo. With remove (and add), there are actually 3 steps:
Delete local copy from your local file system.
Issue cvs remove command.
[Sometime later] Commit changes to the repo (including the remove you did in step 2).
Eclipse just consolidates #2 and #3 for you via the commit or synchronize functions.
See http://docs.freebsd.org/info/cvs/cvs.info.Removing_files.html