Git is one of the main things an iOS dev has to know. Xcode 5 allows creating .git within the project to assist code versioning.

To enable git for an existing project:

– Navigate to that project (in Finder) and open the terminal at that folder, then:

1. git init
2. cat > .gitignore // write to the .gitignore file
.DS_Store
xcuserdata
RestKit     // or any other linked library project 
// Control-D to write and quit cat
3. git add . // add all to git
4. git commit -m "Project initial commit"  // first commit

Change last commit message:

git commit --amend -m "New commit message"

Git commands

Getting and Creating Projects

  • init  – create git and initialise.
  • clone  – clone a repo,

Basic Snapshotting

  • add       –  add the changes to index
  • status   –  list the new files & the modified files currently not committed
  • diff        –
  • commit  – commit all the changes that has been made
  • reset       – drop all the changes and reset to the latest commit
  • rm, mv
  • stash       – copy the changes , making it ready to be apply again
Advertisements