Let's say I remove a line from a file and I commit and push that change:
commit 4dd87
$ vim myfile.txt //remove line from file
$ git add myfile.txt
$ git commit -m "line added"
$ git push origin master
Now, I make another change and I push it:
commit 84674
$ vim myfile.txt //make another change, whatever
$ git add myfile.txt
$ git commit -m "another change"
$ git push origin master
Now, I want to recover the line that I removed in first commit. I would do it with the next steps:
1) Go to commit previous to remove the line (previous to 4dd87) with git reset --hard 4dd87
2) Apply changes of second commit with git cherry-pick 84674
3) Force push with git push origin master --force
But there are many drawbacks using this approach when there are more people pushing to the repo.
So, is there a better way?