1. The console cd to the project directory, enter the command: git init
2. Create xxx/project_name.git on the git server and enter the command: git --bare init
3. Local console:
git add . git commit -m "first Commit" git remote add origin [email protected]:tingkongwanli/git.git git push -u origin master
4. In this way, the creation is successful. You can add git to xcode, and then check out (the first time), and then there will be updates to pull the latest code from master.
5.New a branch, then you can write your own part of the code. After writing, you can commit (local)
Note: merge from branch----merge from elsewhere into my branch
merge into branch----merge my code into other branch
6.push: used to finally send to the server. Switch back to master, merge from branch, merge the latest modified branch code to master, and finally push to server
Reference: http://www.jianshu.com/p/103d74b69a13
Notice the Git ignore UserInterfaceState.xcuserstate issue:
1. Create .gitignore, the function is to let git ignore custom rules;
2. In the project directory, create a new .gitignore
touch .gitignore open .gitignore
3. Enter in gitignore
*.xcuserstate project.xcworkspace xcuserdata UserInterfaceState.xcuserstate project.xcworkspace/ xcuserdata/ UserInterface.xcuserstate .DS_Store
4. Enter at the command line:
$ git rm --cached path/to/.DS_Store $ git rm --cached *.xcuserstate submit: $ git add .gitignore $ git commit -m "Remove and ignore .xcuserstate and .DS_Store files."
At this time, when you merge in xcode, you will be prompted to commit:
Console input command:
git rm --cached ProjectFolder.xcodeproj/project.xcworkspace/xcuserdata/myUserName.xcuserdatad/UserInterfaceState.xcuserstate git commit -m "Removed file that shouldn't be tracked"
Merge again, success
Note: You have to switch to the branch in question to find UserInterfaceState.xcuserstate, or will you report an error