Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Git and Xcode

Git and Xcode

Pulling, committing, pushing, and resolving conflicts

leveton

June 11, 2012
Tweet

More Decks by leveton

Other Decks in Programming

Transcript

  1. Git and Xcode • Git is build into Xcode 4.3+

    • If you're not using 4.3+, then you must download it from the App Store • We're going to learn how to pull, commit, push, and resolve conflicts
  2. git pull pulling allows us to sync any changes made

    by other developers so that our project is up to date. in xcode go to file > Source Control > Pull... You should see something like this:
  3. git pull After entering your username and password, it will

    load the remote branches. Make sure you choose origin/master. You should get a message indicating a successful pull. Now your project is up to date.
  4. git commit After pulling, you've done some coding and you're

    ready to commit. Make sure you save! go to file > Source Control > Commit... You will see a window with your new changes on the left and the code you changed on the right. Before you commit, you must add a message. Make sure your message is descriptive e.g. ' changed viewDidLoad method in SignedIn.m' now hit the blue commit button and you're ready to push to github.
  5. git push Now that you've committed your changes to your

    local . git file, you need to push your changes to github so that the rest of us can pull. file > Source Control > Push... make sure you choose origin/master like below Choose push and the green light should change to 'Push Successfull' You can now see your changes on github
  6. resolving conflicts Let's say you change line 11 in SignedIn.h

    but another developer changes the same line and commits it to Github before you committed your change!! When you go to push, you'll get the following warning: It's telling to pull first, but when you do a pull procedure, you get the following error window...
  7. resolving conflicts This is the conflicts window. The left pane

    shows your changes and the right pane shows the remote changes. The changes are on the same line and are different - so they are in conflict. In the conflicts window, at the bottom-center, you'll see 4 buttons. • the left most button allows you to keep your changes on top of the remote changes. • the next button allows you to keep just your changes. • the third allows you to keep only remote changes. • the last allows you to keep the remote changes on top of your changes.
  8. resolving conflicts Review both changes, keep the ones you want

    to keep and then hit 'Pull' at the right to pull just like normal. You can now commit and push resolved conflict to github like you normally would. Thank you!