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.
- You branch off of
dev
branch - Update your pods
- Make some commits
- Update your pods again
- 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.
- Updated Pods
- Change 1
- Change 2
- Updated Pods
- Change 3
- Updated Pods
- 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.
- Change 1 (sha1)
- Change 2 (sha2)
- Change 3 (sha3)
- Change 4 (sha4)
- Updated Pods (sha5)
- Updated Pods (sha6)
- Updated Pods (sha7)
You have successfully separated pod update
s from your regular commits. Now you will create two branches.
- Pod update branch
- 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