0

I replaced 3 files in a directory in the master branch. For instance, I replaced a.txt, b.txt and c.txt with same name but new content. Then I added in the stagging area, commited and pushed to the central repo.

Whole operation was performed by Root user, later I realized that I had to perform the operation from puppet user.

The steps I took were reverting back to the second last commit. After reverting, I saw the replaced files were still intact with new content in the directory. Furthermore, the revert operation in "git status" was also marked as root user too.

How can I undo the changes locally and remotely and then perform with puppet user.

Fahad
  • 5
  • 3
  • You probably meant "reset" not "revert"? https://stackoverflow.com/questions/27032850/what-is-the-difference-between-git-reset-and-git-revert – evolutionxbox Oct 17 '22 at 17:01
  • I want to undo the local change and remote change too. Then do the local change and the push to remote using puppet user. – Fahad Oct 17 '22 at 17:07

2 Answers2

0

You want to chown recursively using the puppet user so all files are owned properly. Then you can commit those changes and push. Make sure you're doing this under the puppet user.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
0

Let's say the hash of the commit you want to rollback to is 9650a10. Let's roll back the local changes and get back to this commit. To do this, you can use the following command:

git reset --hard 9650a10

After that, you can make a new commit. Then, to push changes with a "correct" commit to a remote repository, you can use the following command:

git push -f
Ivan Yuzafatau
  • 449
  • 4
  • 11