Git add is ignoring certain files even when .gitignore does not exist - gitignore

I am facing a rather strange issue with my git working folders. Here's the summary:
I previously had a local git repo with a .gitignore file that ignored certain files/folders.
I deleted the repo (.git folder) and also the .gitignore file
Then I initialized a new one with git init in the same folder. Now when I do a "git add .", the previous ignore pattern is retained for some reason.
Even stranger,this happens with any new project following the same folder structure no matter where I place the project on my computer.
I tried deleting and recreating the files multiple times. I even created a new .gitignore file with a different pattern. It does not seem to have an effect except when it is set to ignore everything (with just * in the file)
My guess is that the .gitignore pattern I deleted is somewhere saved that I dont know the location of. If anyone has faced a similar issue or know what I could be missing, I'd love to know.
I am still new to git. Sorry if this is something very obvious that I have missed out on.
UPDATE:
I still have not found the reason for this behaviour but managed to reset everything by doing 'git add --force .' in the directory and then deleting the repo. Now I initialized a new repo that works as expected.

Related

How to end 'another git process' running in same repository?

After my first attempt at committing a couple of large folders (angular and django), git responded with:
Another git process seems to be running in this repository, e.g.
an editor opened by 'git commit'. Please make sure all processes
are terminated then try again. If it still fails, a git process
may have crashed in this repository earlier:
remove the file manually to continue.
Previous posts recommend:
removing the index.lock in the .git folder.
I've done this, but the second that i resubmit "git add . " as part of my git push origin master routine, the index.lock file reappears in .git
Is there another solution? And what has happened to warrant this?
I've tried all the suggestions in the commented link
I'm working with this:
git version 2.13.5 (Apple Git-94)
In my case, index.lock wouldn't delete. Instead, I found that one of my django folders lacked a .gitignore, so I created one and included the following files:
include
lib
include
bin
.vscode
You might want to include more or less, depending.. Apparently, I was attempting to push a file that disagreed with git.

How to prevent a folder from being pushed to mercurial repository?

my problem is quite simple: there is a folder in my project which I want versioned, but not pushed along with the rest of the project when I push updates. The situation is that I made an Android app stub along with the project, and I don't want to push it until it is actually somewhat functioning. It's a pretty bulky folder.
I do not want to make a separate branch for that folder, because of two problems: firstly, updating that branch whenever I pull from remote will require a merge; secondly, swapping between the two branches requires noticeable waiting time as the thousands of Android files are created/deleted, and this is very annoying to me.
I was thinking about editing .hgignore in some way, but I think it is wrong that the remote repo will then have my local folder as ignored.
Any suggestions?
You can add this snippet to your repo's hgrc file:
[ui]
ignore = /path/to/.hg/hgignore
where the point about this hgignore file is that it is non-versioned and local to you. The contents hgignore can be anything that would also be suitable for the (versioned) .hgignore. e.g:
syntax: glob
/directory/to/ignore
The name of the file, hgignore, can be called anything, but it's what I use.
You can use the configuration [defaults] section to add some "--exclude" options to usual commands (see my answer to Mercurial hg ignore does not work properly ) for more details. You can even specify which files you do not want to commit in your directory, e.g., stub/**.c for all C files in the hierarchy of directories below stub.
But.. be careful that it is dangerous to silently ignore modifications to files and also that this [defaults] section has been marked as deprecated (it is still present in 2.9.2).
If this is a temporary situation, it would solve your problem though: you would just have to remove the --exclude parts when you feel ready to commit and push your stub.

Can't add new file to repository in EGit

I'm using EGit with Eclipse Juno.
I worked with a local repository and the world was good.
Even adding a GitHub repository seemed to be fine. I added it to my local repository under "Remotes", so I can easily push commits to github.
But after a while, I noticed that no new files are added to the repository, even if I'm commiting changes.
They just are not under version control. They have no symbol, which should mean they are ignored.
This is my .ignore
.gwt
gwt-unitC
ache
Versandanzeige_Web_proto.war
Versandanzeige_Web.war
war/ajax
war/WEB-INF/classes
war/WEB-INF/deploy
www-test
The files are in src, so not even close.
The new files don't appear in the Commit-Dialog, even when checking "show untracked files". They don't appear in the Staging-Window.
RK -> Team -> "Add to index" doesn't help.
The files have the same right and are owned by the same user
They definetly dont show up at github
Any ideas how to fix that? Any additional information needed?
Update:
There are no errors in the error log.
I do have (HEAD) next to my newest branch.
More details:
I got my trunk T, beginning at T0. At T1, there is a branch A, which has changes to T1.
At T2, there is another branch, B. It has no changes to T2.
The strange thing: it is not indicated in History view. The master branch is also missing.
I can still switch to them. When I do git reflog, there are no entries before or including T2, just everything afterwards.
I removed the branches without commits:
The new files are still shown as ignored:
Output from command line:
$ git branch -a:
* master
maven
$ git status
# On branch master nothing to commit (working directory clean)
About the detached HEAD proposel: I didn't do what is described in the article, checking out an old state and work from that. And I can't see any undone commits.
Sorry for my bad english, I didn't use it for a while. Please ask for clarification, if I write something hard to understand.
Update:
I could add a file in another folder (/Versandanzeige_Web/war/WEB-INF/lib/gwt-servlet.jar).
Alright, I found the error.
For some reason I don't really know, there was another .gitignore file ABOVE my Project folder (in repository folder), where my COMPLETE project folder was included. I really don't know how that happened. Of course, this file didn't show up in Eclipse.
I tried to add the files on the command line, but gut the error message "File is in .gitignore file".
After deleting that file, it worked find.
Sorry for the trouble.
Sometimes EGit does not work properly and add to index does not work. In that kind of situations you can go to the root folder of your project (where .git folder is placed) with a file explorer, right click on an empty area inside the folder, select "git bash". This will open the git console for you. Now type "git add path_to_file". This will add the file to the git system for indexing. Now go and refresh your project in eclipse and you will see it is added to the index. This can be used wile resolving conflicts inside eclipse because adding to the index indicates "mark as merged" to the git system by re-adding the merged file.
Also sometimes the "Remove from index" does not work in eclipse, you can do the same thing in that kind of situation: this time write "git remove --cached -f path_to_file". Here do not forget to add "--cached" because otherwise your file will be deleted. -f stands for "force" to force the command. For any folder (directory) to remove from index type "git remove --cached -r -f path_to_folder".

Git with Xcode, no such file or directory

I've been searching around and looking for answers but I haven't found something that works yet. I apologize if this is easy and someone has already answered this as I'm new to Git.
What happened was there was a branch both my coworker and I were using. There was a conflict when I tried to commit (I honestly can't remember if it was committing or when I Pulled in her changes). Basically we were both deleting unused files, images, etc. I went through the conflicts and I thought I went through it properly accepting both of our changes, but something still might have gotten messed up because I'm getting
No such file or directory
For a specific image. These are some of the things I tried, with cleaning and rebuilding after I have tried one of these which have not worked.
- Adding the image back to the project (Xcode still thinks its missing and doesn't update it's .xcodeproj)
- git reset HEAD <file>
- git add <file>
Nothing seemed to work. When I try git status, I saw that it is an untracked file. I then removed it. I see my .xcodeproj is
$10 says the .xcodeproj doesn't recognize the existence of the image. Git does a very poor job of properly merging the .xcodeproj file, and you will often have to readd files due to a bad merge.
When in doubt, find a past version of your .xcodeproj that works, bring it to your master HEAD, and add the files that are missing from the .xcodeproj.

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.