Xcode Source Control Git - xcode

When you create a new xcode project, there is a checkbox, which you can check if you want to use a git repository on your mac. I did not check that box, so right now I don't have access to source control resources. How can I start using git with my project?

I think you would just need to setup a local git repository.
Open terminal on your Mac and type the following commands:
cd <DirectoryYourCodeIsIn>
git init
git add .
git commit -m 'initial commit'
Also, restart XCode after this is completed.

Related

Cannot add repository account in Xcode

I don't know why I cannot add a repository account in Xcode.
Product -- Version
Xcode -- 7.3.1
git -- 2.8.1
OSX -- 10.11.5
screenshot from xcode/preferences/accounts
I found the issue. Under preverences / source control, "enable source control" was not checked. Once checked, I was able to add my GitHub remote repository.
You can connect your project to your repository with git bash like this:
$ cd /your/project/path/
$ git init
$ git remote add origin git#github.com:ali/first_app.git # Or other repo URLs
$ git push -u origin --all # pushes up the repo and it's refs for the first time
$ git push origin --tags # pushes up any tags
Hope be useful.

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.

`git add` doesn't add files to track on Windows

I have a local folder which I wanted to convert to a Git repository and then push to a remote repository. I ran the command git init in the project folder and then used the command git add .. When I run the command git status, I get the message that I have untracked files. I ran the git add . command multiple times but I see the same message.
What should I do to track these files so I can push to a remote repo?
I'm using Windows 8.1 x64 machine.
UPDATE: Please see the answer below.
I used the command git config --system core.longpaths true to fix the error for longer file names. I was able to add all files after making that change.

New Xcode project with Git show warning

I have set a new test project to see how to use git, so I have checked GIT when creating the project. Then I have pressed on the create button and got a weird warning (attached).
Then I have opened the project and all the files were marked with A (They shouldn't) as git
should commit them on the project creation.
Any idea how to configure a user for git?
I have also tried to open terminal and write the line from the error with my email. it didn't worked.
I use xcode 4.6.1
Executing the following two commands from the terminal should make sure you won't get this error in the future:
git config --global user.email "IOS.DEV#mail.com"
git config --global user.name "IOS DEV"

Git Repository Created Manually Can't Commit

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.

Resources