I have a git repository that I push to from development and pull from test and production.
Say I made 17 commits so far, and all the servers are in synch.
Now I want to revert to commit #15 on production, but not only a (few) file(s): I want all the files on my production server to reflect commit #15.
I also prefer not to create a new commit for this, and also to be able to roll forward to the latest commit, or other ones from the central repository.
My first guess is to run it without declaring any files, e.g.,
git checkout [commit-15-SHA1]
Is there a better/safer to do it? What is the git way?
If you want to revert, and then branch from commit #15, keeping all the revisions AFTER commit #15 intact, yours is a good approach.
If you just want to “back up” in commit history, without losing your current changes, and two most recent commits, then try a soft reset.
However, if you want to nuke everything you changed, including all revisions AFTER commit 15, then you do a hard reset.
Read more about git reset here.