I am using git with Xcode but when i commit files using Xcode (not command line) after committing and pushing to remote, when i use git status this is the result.
What are Untracked Files. What should i do with them?
And what about Changes not staged for commit part? What are they?
These untracked files are files that have been added to your directory structure (e.g. it would appear that you did a pod install), but you have neither added them to source control nor told git to ignore them. (I would tell git to ignore them, personally.)
But you have to decide whether you want to add the Pods directory to your repo or whether you'd like to ignore them. See https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control. (I personally don't put Pods into source control, just the Podfile and Podfile.lock. There are many opinions on that topic, though.)
Re the .DS_Store, we often have a ~/.gitignore_global that tells it to ignore those, too. Once you tell it to ignore these, they will be removed from the “untracked” files list. See .gitignore all the .DS_Store files in every folder and subfolder.
Re the unstaged .DS_Store it looks like your repo already had that one .DS_Store in the repo. I would suggest removing it from the repo. See How can I Remove .DS_Store files from a Git repository?.
In short, it looks like you have a project with no .gitignore file (or it is missing entries). It also looks like you don’t have a ~/.gitignore_global to ignore .DS_Store files.
For an example of a .gitignore that you might use for Swift projects, see https://github.com/github/gitignore/blob/master/Swift.gitignore (though, like I said, I generally would uncomment the Pods from that particular .gitignore).
Related
I took over an iOS project completed by objective-c. The project does not use git, and I want to use git to manage it locally.
I performed the following steps, and then when I submitted, I didn't know which files to add to the tracking file. (I created git to ignore files)
Steps i did
I opened the terminal and entered the following command:
cd /Users/xxx/Desktop/xxx/Myproject
git init
touch .gitignore
open .gitignore //I manually added the ignore rule in .gitignore and saved
git status //我没有修改任何代码,而且没有执行 git add ,因为我不知道该添加哪些文件到追踪文件
This is ignore file
Should I execute git add .? Or should I choose some additions?
I hope you can tell me the method and reason, I do n’t understand what I found on Google.
I had not heard of this file until I randomly checked git status in an old repository and there it was, a file I had not edited myself nor ever seen before. I do not know how it got there.
It seems it's common asked about - mostly how to remove it (e.g. here and here).
What is this file, and what created it?
.idea is the dir for saving the project configurations for all Jetbrains IDES (RubyMine , Pycharm , PHPStorm , WebStorm ..etc)
you can handle it using two ways if you don't want to commit it to the repo
Ignore it only for yourself
in .git/info/exclude
add /.idea
Ignore it in .gitignore so it will be ignored for everyone who uses the repo
by adding /.idea to .gitignore
if the dir .idea already tracked by git you will need to remove it first from the cached files before ignoring by git rm -r --cached .idea
This folder can include important configuration if you did any custom configuration for the project and also include the indexed data for the IDE which helps it to provide quick autocomplete and in certain cases would be better to commit it to the repo but I always ignore it because the other developers in the team don't use RubyMinee
I pushed my code to repository, I can see the MyProject.xcdatamodel/contents file in bitbucket along with other files. But when pulling the repository, all files are added except the coredata file MyProject.xcdatamodel/contents. Am I versioning the right coredata files? Thanx.
EDIT:
here is my gitignore file:
.DS_Store
*.swp
*.lock
profile
DerivedData/
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
# NB: also, whitelist the default ones, some projects need to use these
!default.pbxuser
!default.mode1v3
!default.mode2v3
!default.perspectivev3
*.xcuserdata
!xcshareddata
!xcschemes
*.moved-aside
*.xcodeproj
.xcworkspace
Ignoring files
From time to time there are files you don't want git to track. There are a few methods of telling git what files to ignore.
If you create a file in your repository named .gitignore git will use its rules when looking at files to commit. Note that git will not ignore a file that was already tracked before a rule was added to this file to ignore it. In such a case the file must be un-tracked, usually with git rm --cached filename
This file can be committed into the repository, thus sharing the rule list with any other users that clone the repository.
Note that you can create a .gitignore in any subpath to have its rules applied at that path. Sometimes an empty .gitignore file is used as a placeholder for an empty path, for example to force git to generate a log/ path for your development environment to use.
Example .gitignore file
*.exe
*.dcu
*.dres
*.local
*.identcache
__history/*
Win32/*
Win64/*
As standard, I'd setup the ignore file as:
xcuserdata
project.xcworkspace
.DS_Store
And add from there as required.
Not sure why you'd want to add *.xcodeproj into your ignore file. This is the main repository of project information. Whenever you add files the the project (like adding a model version) you want the change to be recorded in the project...
There are some things inside the xcodeproj file (it's really a folder) that you can ignore, but you shouldn't ignore the whole thing.
I have made a naive mistake while setting up my project. We are 3 developers working on one remote repository. While setting up git we never thought that Xcode would produce non-development files and push them to our remote repo. Now once I learnt after crash and burn I made a .gitignore file.
.gitignore looks like this, please do let me know if I should edit this too. (File credit goes too : This question's answer given by Abizem)
# Mac OS X
*.DS_Store
# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/
But now question is there any possibilities that I can untrack all of those listed files from our source control?
or
Can I list all tracked files with their path and later I know a painful way to remove one by one with,
git rm --cached 'file path'
Something I've done a few times in these situations, is move all of the files in the repository somewhere else on the filesystem (except .gitignore), then run:
git add --all
git commit -m "Remove all files"
Then add your files back in and run the following:
git add --all
git commit -m "Re-add files"
This second add & commit will adhere to your gitignore file.
I ignore *.sqlite3 file both in the project directory and the global gitignore config, but after that the sqlite3 file show in the git modified log every time.
How can I fix that?
If the file(s) is already in the repo ( ie. it is versioned ) it will continue to show as modified if you make changes to it. To make git start ignore them, first unversion the files ( using git rm --cached and git commit )
If the file is in the repository, then ignoring it will have no effect. Remove it from the repository, or mark it as unchanged.