Git Repository Created Manually Can't Commit - xcode

After creating a Git Repository using the terminal application using the following commands
Focusing the shell on the project directory
$ cd ~/Desktop/Myproject
Setting up the Git Repository
$ git init
Preparing the files for the "staging area"
$ git add .
Making my first commit
$ git commit -m 'Initial Checkin'
When I now try to commit in Xcode, I get
The operation could not be performed because no valid working copies were found.
Please verify that your files are under source control and try again.
But if I modify any of the project files and $ git status in to shell, it will tell me that what ever file I fiddled around with in Xcode has been modified and the I can commit from there. Why not in Xcode??
I had a loot at Can't commit changes to local git repository but the suggestions did not solve the problem.

If restarting XCode doesn't help, since you are saying it works fine through terminal, try adding it again in XCode.
go to Organzier--> Repositories --> Add Repository (bottom left corner)-->Set the correct values and local path to your project
my guess is, since you created the repository outside XCode, for some reason, its not detecting it right, or is not having the right permissions. Re-adding the repository through XCode may help solve this issue for you.

I had this happen once, and the issue was cleared by quitting and re-opening Xcode.

Related

Git Errors with interactive rebase. Unable to move the cache: Access is denied

I'm using Git on windows on version 2.38.1
I'm currently having some errors when I'm trying to do an interactive rebase. Fortunately the operation still works at least. Here are the errors :
I tried the following:
Delete the cache folder. This only brought more issue where I was not able to clone repos
reinstalled git for windows. This solved some of the issue but I still have the errors that are in the screenshot
I found a couple of forum/blog that gave me things to try bu as of now it always led me to another dead end.
Would anyone have a clue on how I could get rid of those errors?
Thank you in advance for the help
Try first to make the git rebase -i from a simple CMD session, not from an editor (like VSCode) to see if the issue persists.
Do that in a local cloned repository in C:\users\macaron\myRepository (replace myRepository with your actual repository name).
If it works outside an IDE, but not inside, then, as seen here, it is probably due to a concurrent process which keeps an handle on those resources (Cache folders), preventing the git command to proceed.

pre-commit hook not working in macOS but working in Ubuntu

I have a git pre-commit hook script to validate certain thing during commit.
This in my script .githooks/pre-commit
#!/bin/bash
echo "Here I am!"
This is the file permission
In ubantu when I am committing anything I am able to view the echoed message, where as when I doing the the same thing in MacOS I am getting this error
fatal: cannot run .githooks/pre-commit: No such file or directory
git config is .git/config
line break type is CRLF
Also when I am directly running the file (in MacOS) from CLI like this, it is giving me the desired output.
./.githooks/pre-commit
My git version is 2.32.0 (Apple Git-132)
could you please try this and see if it's working for you?
brew link --overwrite git
brew update git
You should have the latest version of git -> 2.35.x
Now go to your local repository, i.e. the project folder, and then to the .git/hooks directory under your project folder.
You can place your hook files here. I.e. for pre-commit, the file name should be pre-commit (without any extension).
This should work whenever you try to commit to that specific repository. The main problem in your case seems to be the directory. The hooks should be in the .git/hooks directory of the project folder.
See the screenshots below.

ReadMe file won't allow me to commit and push xcode changes to github

I have an existing xcode project and repo on Github. I recently added a ReadMe file which was suggested by Github but now I can no longer commit and push changes to Github. I keep getting an out of date message. How do I fix this problem?
I had the same experience of adding README.md with the same error.
If you don't want to git pull, because the remote version in Github is outdated.
You can also force push all local branches using:
$ git push -f origin master
The following commands in the Terminal will push your local Xcode project to remote Github.
cd <drag location folder of project>
git init
git push -f origin master
You need to git pull.
If you're using the command line, navigate to the directory of the repository and run git pull. If you're using another interface, the steps may be a bit different.

warning: templates not found /usr/local/git/share/git-core/templates

I get this error warning: templates not found /usr/local/git/share/git-core/templates when I cloning repo in local repository this link, this link, and this link I tried this method and I just waiting more than 20 minutes but repo doesn't clone. I use source-tree and OS X El Capitan. How can I fix it?
Create a templates folder.
In your case, it should be: mkdir /usr/local/git/share/git-core/templates
I was also getting same error
warning: templates not found /usr/local/git/share/git-core/templates when I cloning repo in local repository then i found solution which solved my issue.
I Added the [init] section to .gitconfig in home directory, so that it looked at SourceTree's git templates directory when cloning a repo:
[init]
templatedir = /Applications/SourceTree.app/Contents/Resources/git_local/share/git-core/templates
Hope it will help you!.
In case of Source tree on macOS
Steps:
Source tree Menu
Preferences
Git
Click on System Git under Embedded Git Version 2.2.1
Reset to embedded Git
Restart source tree
Similar to Rohit's answer, I went into SourceTree's Tools->Options->Git and selected "Update Embedded Git". After the latest Embedded Git version was installed, the warning stopped occurring.
Cloning via SourceTree for Mac, the download was stuck at 99% and I was getting the same error:
warning: templates not found /usr/local/git/share/git-core/templates
I started looking up the issue and found this Question. Was about to start with some of the Answers here...
But then it finally completed. So, my Answer: wait a bit longer. Mine was cloning for 10 minutes or so.
#wonderfulthunk's comment works for me:
sudo mkdir -p /usr/local/git/share/git-core/templates && sudo chown -R my_username /usr/local/git
I followed below steps and I am able to get through this issue in Windows 10.
Step1:
First know the path of %USERPROFILE% using below command in command prompt.
echo %USERPROFILE%
Please note that, you can also run git config --list and look for init.templatedir for the path.
Step2:
Look for .git_template folder in it.
If is missing, please run below command to add it.
git config --global init.templatedir "%USERPROFILE%.git_template
Step3:
Create a folder namely templates in it.
After creating this templates folder, I did not get the warning mentioned i.e. 'templates not found' any more.
MacOS: Ventura 13.0 /
Sourcetree: 4.2.0
I fixed warning: templates not found /usr/local/git/share/git-core/templates by going to "Sourcetree preferences -> Git" and clicking to "Use System Git". There's no need to restart Sourcetree, just try to clone again.
I didn't switch to usage of embedded Git again, all works perfectly with usage of System Git.
In my case, this happened because an unaccesed project. Check that you have all the privileges to clone that repository.
If you use Sourcetree application, switch git version from "Embedded Git" to "System Git" in setting.
https://community.atlassian.com/t5/Bitbucket-questions/About-git-path-for-Sourcetree/qaq-p/186483
And after changing git version, if you still have problem with cloning, change protocol from "ssh" to "https".
I couldn't get past this problem. Even after getting rid of the 'templates not found' error by adding the usr/local/git... folder, the clone would still look like it was at 99% and sit there for HOURS. I just clone via command line and it's there in seconds, then I just add the local repo to Sourcetree instead.

Git push halts on “Writing Objects: 100%” on Windows 7

When I try to push new file into Git repository, it doesn't finish, on screen is my workflow:
I tried:
TortoiseGit 1.8.1.0 (git version 1.8.0.msysgit.0 (C:\Program
Files\Git\bin))
Eclipse EGit 2.1.0
Command line
without any success. I read this question, but it's quite old (1.5 year), and do not help (I installed git 1.7.4), and was the same. I new in Git, please tell me what am I doing wrong or how to solve it? What do you suggest as a Git client for Windows 7 (32)? (Best if it will support command line).
Pushing over the Git-protocol is still broken in Git for Windows. So if that's what you're attempting, check if you can push over another protocol instead.
I had this problem today. I pulled and then tried to push to the remote, and it got to 100% writing objects and just stayed there. It didn't request the repo password, nothing.
The solution was related to my .gitconfig file. I had to redo the settings in this file.
I think in mucking around with my git repository (and admittedly learning how git works by breaking it) I had inadvertently removed this file.

Resources