Tip on pushing commits with Cocoapods changes

I am not sure how regular this practice is but some developer teams tend to push cocoapods Pods folder along with regular project commits. This actually leads to case where you update your pods along with your local changes. When your changes are along with same commit when you updated pods, it can lead to confusion for other developer who review your code.

Imagine this scenario.

  1. You branch off of dev branch
  2. Update your pods
  3. Make some commits
  4. Update your pods again
  5. Make your commits

Now when you're about to merge your changes into dev, you have your changes plus bunch of other changes from your one or more pod update which you don't want reviewer so see since you didn't really make them.

What do you do in this case?

My approach is to go with commits re-arrange. You can use Interactive git rebase to re-arrange all the past commits.

For example, say you have following git history.

  1. Updated Pods
  2. Change 1
  3. Change 2
  4. Updated Pods
  5. Change 3
  6. Updated Pods
  7. Change 4

Using link above, you can rearrange them as follows to put all the Updated Pods commits in the beginning of commit history. I have also added sha message beside them for a reference.

  1. Change 1 (sha1)
  2. Change 2 (sha2)
  3. Change 3 (sha3)
  4. Change 4 (sha4)
  5. Updated Pods (sha5)
  6. Updated Pods (sha6)
  7. Updated Pods (sha7)

You have successfully separated pod updates from your regular commits. Now you will create two branches.

  1. Pod update branch
  2. Feature branch

Now run the following commands,

git checkout sha5

git checkout -b pod-updates

git push -u origin pod-updates

Now this is your branch for exclusive pod updates and you have already pushed it to the origin.

Now run following commands,

git checkout sha1

git push -u origin feature-branch

Now go to gitlab and create an MR to merge feature-branch into pod-updates and assign to your teammate. Since you separated pod update changes from your feature changes, this MR will only have your feature changes and not pod update changes.

Once your teammate approves these changes, you can merge feature-branch into pod-updates and then safely merge pod-updates into dev.

This strategy will help to keep you from having to review pod update changes. The only tricky thing here is to understand how to reorder commits with interactive git rebase and then separating pod update changes from regular feature update changes.

I would like to hear what do you think about this strategy. If you have any other strategy on pushing commits with Cocoapods changes, I would love to hear it

Jayesh Kawli

I am a web and mobile developer working at Wayfair in Boston, MA. I come to learn so many things during course of life and I write about things which helped me and feel like they can help others too.

Subscribe to Fresh Beginning

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!