2

Question

Given an already pushed commit sha1 that contains a change to a submodule, and some other changes to other files, how do I revert only the change to the submodule, but keep the changes to the other files? (I.e., it is not an option to revert the whole commit.)

Attempt so far

I tried this, based on the answer in the related question:

git show some_commit_sha1 -- path/to/submodule | git apply -R

but obviously it does not work.

I would be surprised if it did, as the diff is just this:

git show some_commit_sha1 -- path/to/submodule
[...]
-Subproject commit abcdef12345....
+Subproject commit 98765432109....

(I guess git apply -R can't do much with that.)

Related but not duplicated questions:

Revert changes to a file in a commit This is exactly what I want to do, however not with a file, but a submodule.

How do I revert my changes to a git submodule? This is for reverting "local" (not yet committed) changes

Git submodule revert commit Title seems to be exactly what I need, but then the question asks about something else (if I understand correctly it's about changing the content of the submodule on various branches)

Attilio
  • 1,624
  • 1
  • 17
  • 27

1 Answers1

0

Submodule Commit Revert

First go to command Prompt Then go to submodule that you want to revert.

1) cd ../submodule name

commit id will be available in GIT commits in difference in PR.

2) git checkout commit id

Check git Status

3) git status

See output on command prompt submodule look like in Red colour , just check.

4) modified: ../submodule name

Then add changes to GIT for push.

5) git add ../.

Check status again

6) git status

See output on command prompt submodule look like in green colour, just check.

7) modified: ../submodule name

Then Push changes to GIT

8) git push

Note : if push not done form command prompt then you can push through Android Studio in case of android OR Source Tree OR some other GIT editor.

Android Studio is better option in case of android if you can only revert specific part of files of wrong submodule commit , for tease you can only select those files that should only get merged wrongly.

Chetan Joshi
  • 5,582
  • 4
  • 30
  • 43