Cannot save changes in file under Git version control - windows

I forked and cloned a project from GitHub and I can make changes to all files but one.
It's .xml. When I make changes and hit the save button, the file reverts back to its original state.
I've done git config core.fileMode false but to no avail. I've also checked the file permissions and it's -rw-r--r--. Same as other files I can edit.
Please, how can I solve this problem?
The last time, I had to go to Git web and make the changes there before pulling.

I realized the file I was editing is in a directory in the .gitignore.
So maybe git was undoing the changes I was making.

Related

How to enable .gitignore file in private repository in GitHub with GUI

I can't uploud a project in private repository even I'have .gitignore file(where I made a mistake, because .gitignore doesn't work). Message is that I have more than a hundred files, and simply I can't uploud it in one piece, just one by one folder or file.
I have make a new private repository in GitHub, and at the start of making it's offering to make a gitignore file, so I done that step(I chose a Visual Studio gitignore file, and then I put all files I don't need, even a whole folders I don't need from my project I've made in VS). But problem is in uplouding folders after I make the repository. Every time I try to uploud it, I get a message that I have more than a hundred files. I've even opened a whole new private repository in case git alredy tracked the files in this one. And it seems nothing is working. I have reed all official documentacion about gitignore files in GitHub, I've seen a bunch of Youtube tutorials and tryed to make a gitignore file direct in VS but also doesn't work.
Maybe it's seems funy to most of you and it is probably a banal mistake but I just can't figure this out.
SENCE I'M A TOTAL BEGINNER please can anyone tell me where I make a mistake?
Here is a piece of my .gitignore file, most of it is official code, and it is very big.
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
App_Data/
Content/
fonts/
Scripts/
*/favicon.ico
*/packages.config
I just want my whole project uploud it in one piece without unnecessary files from VS.
List item
I will augment #Harmonica141 answers by suggesting you to use on line .gitignore file generator.
After selecting desired IDE or programming language .gitignore file will be generated for you with all required regex and file exclusion.
After downloading a file you need to add it to the repository by command line.
Do as follows:
cd into/the/repository/folder
git add .gitignore
git commit -m "Added .gitignore."
git push origin
Your .gitignore is active as soon as it is tracked by git. To accomplish that, you will have to commit it. Do this first, make a commit consisting only of that file. Then git should not "see" all the files masked by it any longer.
In command line do as follows:
cd into the repository folder
git add .gitignore
git commit -m "Added .gitignore."
git status
The last statement should show you all the files that are still untracked or uncommitted but not the ones contained in the .gitignore. From there you can keep adding and committing as usual.
Don't forget to push later to have your changes up on remote.

I have deleted my project.pbxproj file using git checkout -- <file>. Should I delete the branch locally and pull from origin?

I have gotten myself into some hot water regarding source control.
I had just gotten a feature branch to work that another developer on my team had created and developed, which required adding some files. He then added some additional code to the project, and I wanted to revert to the version of the branch I had started with before I pulled his new code so that I wouldn't have to worry about merging these new files.
So, as per git's recommendation, I unstaged the changes I had made and used:
git checkout -- ScrollingTextLabels.xcodeproj/project.pbxproj
followed by:
git pull
I had assumed that the pull would replace the project.pbxproj file with the one from the origin, but instead git spat out a lot of lines beginning with "delete mode", most disconcertingly:
delete mode 100644 ScrollingTextLabels.xcodeproj/project.pbxproj
Every time I try to open the project on this branch, I now get the following error message from Xcode:
Project /Users/myname/Documents/Code/organization/product-ios/ScrollingTextLabels.xcodeproj cannot be opened because it is missing its project.pbxproj file.
I have been able to switch to other branches, which are still working fine, and must have their project.pbxproj file.
Also, I attempted to use git reset --hard to no avail. Should I force an overwrite (a la How do I force "git pull" to overwrite local files?)?
Should I delete the branch locally and pull from origin?
All I want is for the remote version of this branch, which is working well, to appear unchanged on my computer so that I can open it and continue working.
The message
delete mode 100644 ScrollingTextLabels.xcodeproj/project.pbxproj
during a merge (or pull) indicates that the file was deleted in the to-be-merged branch. It does not exist anymore in the other branch, your co-worker must have deleted that file.
Deleting a branch and pulling does normally not solve anything. You already have all changes from the remote (probably in origin/branch). Either checkout a new branch from that commit, or reset to it (potentially losing all your local changes!)
Use git log origin/branch or gitk to view the changes of the branch. You can also show the log for this single file only with git log origin/branch -- ScrollingTextLabels.xcodeproj/project.pbxproj. This should tell you, what happened to the file and whether it was deleted in the branch.

How to undo "add to Git repository" after creating an Xcode project?

I created a simple Xcode project to try something out and accidentally forgot to disable the Git repository option.
Now Xcode is cluttered with source control things. How can I get rid of this afterwards other than copying all files by hand into a new Xcode project and making all project changes again?
Not sure I understand your question, but if you just don't want the project to be a Git repository, you can simply delete the .git folder located in the project's root.
if you hasn't shared your commits with others yet, please use "git reset -mixed" or "git reset -hard" to set master to the last changes you want.
if you want to change index and working tree, use something like: git reset -hard HEAD^
if you want to change index only and keep your Xcode as uncommitted , use something like: git reset -mixed HEAD^
see man git reset

Committing source to git via Xcode, failure to commit

I have a repository, in which i code. Once some changes are made, they are checked in to GIT repo via Xcode.
Before checking in .. files look like this - files i have changed look right
Upon checking the code in (Alt-Command-C), all i see is (Note that files seen in explorer window are not seen)
Towards the bottom of the screen, correct number of files are shown
When commit button is hit, no errors are shown, all looks normal, however, nothing (visually) changes:
Explorer continues to show same files modified
Commit screen continues to show some files in need of being committed
Commit screen does NOT show exact files to be committed
I could have sworn that last night all files were committed. Could someone help me understand what's going on here?
UPDATE:
After modifying my .gitignore to include
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/
.DS_Store
*.tm_build_errors
You should probably create a .gitignore file and put it in your directory. The xcuserstate files are constantly changing (and are of no use to your overall commits). Your will always show changes and it will also prevent you from pushing your changes to your remote (if you have one).
There are plenty of places that will show you how to make a good gitignore file.
Git ignore file for Xcode project
The issue it seems was that in my set up, Xcode defaults to File View
When I switched to Flat View, files which were changed showed up
First thing to try it to try to commit the files from the command line.
Run git status to see the state of things, git add <modified files>, and the git commit - you should either see an error or files will be committed.

xcode commit missing file or directory

I'm not sure what happen but when I try to commit my changes in Xcode I get an
fatal: Could not switch to '/Users/charlesbutler/xCode/MA Mobile/MA MobileTests': No such file or directory
I have a bunch of files like this.
Is there anything I can do to remove them from being committed. A lot of them were deleted (probably manually in the project folder by me)
This just happened to me. I had deleted a folder with contents from the project folder. Xcode didn't handle that well.
What worked to fix it was to recreate an empty folder with the same name. No need to recreate its contents.
In your case I think you just need to create a new empty "MA Mobile" folder in the same location the old one was. Then commit. It worked for me.
After the first commit I deleted the new folder, then committed again. It seems that Xcode is missing the logic to handle the deletion of a whole folder with contents.
If you'd like to simply commit all changes you made, doing so through the Terminal should fix the problem.
Open the Terminal App and cd into your project directory, once there type in the following command:
git commit -a
Enter your commit message by pressing 'i' and typing it in, then press 'Esc', then ':', and type 'wq'
All done, you're problem should be fixed.
Jader Feijo's answer solve my problem.
Just want to suggest an easier way to add comment, without all this additional Vi steps, by simply adding -m parameter:
git commit -a -m "Commit Message"
Assuming that you are using GIT - run the following in your command line;
cd "/Users/charlesbutler/xCode/MA Mobile"
git rm -r "MA MobileTests"
I had this problem after adding and then deleting sub-projects in a project that was under source control.
I fixed it by using the GitX application, selecting the Commit View, un-staging the now non existent files from the Staged Changes list, and then selecting Discard Changes for the same files in the Unstaged Changes list.
I then had to delete the repository from the Xcode Organiser-Repositories screen and restart Xcode before things were working ok again. Xcode automatically re-adds the repository back in when the project is re-opened.
Perhaps someone with GIT expertise can provide a command line alternative that performs a "Discard all changes that are no longer present on disk" action
I've had this problem because somehow a folder of the project was added to .gitignore, I removed it from there and committed the missing files. Xcode did not show me that the folder was in gitignore or that he was different from the other folders in any way.

Resources