Adding a File or Folder to a Git Repo in Eclipse - eclipse

I want simply add a new File or Folder to an existing Repo in my Eclipse.
I tried the following (add index on the file and folder), but nothing happens.
Can someone help me.

In Git, a new file must first be added to the index (also called staging area) and then committed before the file becomes part of the history:
Add files:
Right-click and choose Team > Add to Index or
in the Git Staging view move the file from Unstaged Changes down to Staged Changes
Commit files: In the Git Staging view enter a Commit Message and click Commit
Result: In the History view a new commit containing the files is shown.
Please note in Git (in contrast to e.g. SVN) only files, but not empty folders can be committed.

Check the properties on that folder to get its path.
Switch to command line, and do a git status (if you have Git installed), to check if the folder and its content is actually in a Git repo (or if only "src" is):
Chec at least if you see a .git folder above the folder you want to add to the index, you should be able to do so from Eclipse.
But if not, that would explain why adding it does nothing.

Related

Vscode Git commit history shows upper folder's change

I created flutter new project in path /Users/hayat/flutter_development/flutter_project/flutter_application_1.
But VScode shows 10k changes in commit source control.
when I see those changes, it shows all changes in /Users/hayat/, which is upper folder than pwd.
I don't know why it happens and how to make it show only changes of flutter_application_1.
Your probably made a git init or at least have a .git folder in your /Users/hayat/ folder.
Best thing you can do is to delete the .git folder in /Users/hayat/, then you will be able to commit normal changes in your project folder. If VSCode don't detect any git repository, then, use the git init command to link your application folder to your remote git repository.

Eclipse Oxygen - Git Staging NOT Showing File Under Dot Folder

I have a project in Eclipse Oxygen that uses Git. When a file is created or edited it shows in the Unstaged Changes list on the Git Staging View. This allows you to drag the file to the Staged Changes list and then it can be committed.
I needed to create a folder named .sti directly under the project folder and then a folder named bin under that, like this:
project/.sti/bin
Then I had to create a file called assemble in the .stl/bin folder.
The problem is that the file called assemble does NOT show in the Unstaged Changes list. Therefore I cannot stage and commit it.
Is there any way of getting this file to appear?
I'm sure that the .sti folder is the cause of the problem.
Any ideas or help would be much appreciated...
In the end I deleted the .gitignore file in the project folder and recreated it. Upon refreshing the project in Project Explorer, the changed file appeared in the Unstaged Changes.
This was rather strange as the original .gitignore did not specify: .sti

how to rollback the ignore state of a file/folder in git using eclipse

accidently I set the ignore state for a folder in GIT in eclipse.
context-menu on the folder -> team -> ignore.
How can I activate this folder for GIT again ?
I guess it must be team -> add to index, but this doesn't work for me.
any help ?
Click Ctrl+shift+R and type .gitignore in eclipse.
Open the .gitignore file of respective project.
All the ignored file's path will be displayed here.
Now remove the paths of files which you want to unignore and save it.
Again the files will be back to its original stage and can be added to staging area.
Steps to make file unAssumed ignore
If you don't want your files to be ignored then do the following
Go to the file you don't want to be ignored and rightclick it --> Team --> Advanced --> No Assume Unchanged
Please find the same in image
See this bug right now there is no way to find all ignored resource in a git repo using EGIT.
When you do Team context-menu on the folder -> team -> ignore it will automatically create a .gitignore file inside the parent folder and this file is added automatically to git index and will be shown in git staging view.
After committing this file it is difficult to find all ignored resources in a given git repo. Go to your file explorer and search for all .gitignore files inside a git repo and view their content.
In the base directory of the git project, there will be a file called .gitignore (Note the dot at the start of the filename).
This file lists all the files, directories etc that are ignored by git.
Simply edit that file, removing the line which corresponds to the folder you accidentally added.

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.

Mercurial will not recognize new folder in repository

I have an existing repo which has been setup correctly and working fine. I deleted an entire project folder from the repo, committed the change, then added another version of the same folder which was not under VC. Now when I try to add or commit files in the new folder, Mercurial does not seem to recognize any of the new files.
Using the TortoiseHg Windows Explorer "commit" extension, when I try to the commit the folder(or any of the files within), no files show up in the dialogue. If I right click and commit a file within the folder, a pop up comes up that says "No files found for this operation". I am no Hg expert, although I have been using it for few months without a hitch, but I am pretty stuck on this one. Any ideas?
UPDATE: I have added a screenshot below showing what happens when I try to add the new folder. None of the files in the folder seem to be recognized.
The project I had copied had been a part of another repo, so it contained hg reference files. I deleted these, and everything added/committed perfectly.
If you want to commit a new file to a repository, you must first add it.
On the command line this can be done in various ways :
hg add which can add a file or a repository and every files it contains.
hg addremove which adds all new files and remove deleted ones.
hg commit -A or hg commit --addremove which are the same thing and a shortcut of hg add remove; hg commit.
I don't remember exactly where the command is in TortoiseHG, but I think if you right-click on the folder in the explorer, the option should be present.
I think I also remember an addremove option somewhere in the commit window, but I may be mistaken.
[UPDATE]
Based on the answer you provided yourself, here is the explanation of why simply adding the files weren't working :
Since the new directory contained repository related information (a .hg directory), Mercurial was treating it as a Subrepository. Subrepositories are repository contained in another, this can, for example, be used to reference a specific version of a library.
Once you delete the .hg directory in your new location, Mercurial didn's saw this as a Subrepo anymore and you were able to add the files normally.