5

I have some troubles with Github:

When I am pushing my Xcode project to github, it seems that it won't push all files regarding the pods and app extensions because when I pull the project down on my other mac, I get a whole lot of errors that is not there on the original file.

Thanks in advance!

The errors I get

Magnus
  • 895
  • 3
  • 9
  • 20
  • 2
    The files are not checked in. Post your `.gitignore` file. In regards of pods, `pod install` will probably fix the error. – shallowThought Dec 07 '16 at 17:41
  • How do I post my .gitignore file? I have tried "pod install" and it did not work... @shallowThought – Magnus Dec 07 '16 at 17:53
  • @Magnus Please update your title: you seem to understand already that it's _you_ who isn't pushing the files, not Github. Next, follow the steps in my answer to update your question with the contents of the `.gitignore` file, so we can continue solving your problem. – PDK Dec 07 '16 at 23:56

2 Answers2

3

After a lot of testing I found the answer. When I used the command lines in terminal for pushing the project to Github, instead of the shortcuts in Xcode, I saw that this files were not "added" to the committing (I checked this by typing: git status). Then all I had to do was to write in Terminal: git add -A to add all the files. I committed and pushed them to Github, and now everything is working fine!

Thanks for all the help I got!

Magnus
  • 895
  • 3
  • 9
  • 20
2

As shallowThought is suggesting, extend your question with your .gitignore file, so we can identify the lines that are likely preventing git from tracking the pods and extensions.

If you are unsure how to find and copy this .gitignore file, do the following:

  1. In Xcode, on the left open the Project Navigator (folder icon) & select your project (usually the top item in the list).
  2. From the File Menu, choose Show in Finder.
  3. Finder will open with <your-project>.xcodeproj selected. If you don't see the folder that contains <your-project>.xcodeproj, press ⌘ 3 to tell Finder to View as Columns.
  4. De-select <your-project>.xcodeproj and instead drag the folder that contains it onto the Terminal icon (usually in the bottom of the screen). If Terminal was not there, first start Terminal; e.g. by pressing ⌘ Space and typing Terminal.
  5. Now, Terminal is showing the commandline in the same place where your .gitignore file usually is—technically it can be in any subfolder.
  6. Type pbcopy < .gitignore followed by Enter to copy the contents of the file in your clipboard.

… now post the contents in your question.


Another way to check if indeed git is not tracking your desired files is opening Terminal, and running the following command (from this answer): git ls-tree -r HEAD --name-only
If Git is not tracking the files that you require, they will not be in the list.


If you want to solve this yourself, your best bet is to remove the line from the .gitignore file that is preventing Pods etc. to be tracked. So, you're are actually doing the opposite of this SO answer ;-)
In step 3. type open -a "TextEdit" .gitignore followed by Enter to open the file.
Then remove the line(s) that you don't want ignored. Save. Now you can add/commit/push the files to GitHub.

Community
  • 1
  • 1
PDK
  • 1,476
  • 1
  • 14
  • 25
  • Thanks for your help @PDK! In your second suggestion I get a whole lot of names in terminal, but when I try `open -a "TextEdit" .gitignore` in terminal I get the answer: `.gitignore does not exist.`. Should I create a .gitignore file or is it just hiding somewhere else? – Magnus Dec 08 '16 at 07:14
  • _"whole lot of names"_, but *not* the Pods and Extension you're looking for? Then they might indeed be ignored. In step 5. we assumed the `.gitignore` would be in that folder; however, it can be in a subfolder. To try to find other `.gitignore` files, type `find . -name .gitignore` (http://stackoverflow.com/a/5905066/3419541) – PDK Dec 08 '16 at 09:19
  • Hi @PDK. When I did this command I think might have found the `.gitignore` file: `/.cocoapods/repos/master/.gitignore`, but I can´t find a way to open that file... – Magnus Dec 16 '16 at 11:25