does git push unreachable objects to the remote

Viewed 357

If I use git commit --amend then the previous commit (say commit A) is overwritten, which is not completely unreachable since git reflog remembers it.

My questions are:

  1. If now I do a git push, will the commit A be pushed to the remote?
  2. If yes, how about completely unreachable objects (for example, after git reflog expire --expire-unreachable=now to make the reflog forget the commit A)
  3. If no, how to make it be pushed as well
1 Answers

Moved from comments:

  1. There's no "not completely reachable". Either it's reachable, or unreachable (from the pushed refspec). Reachable commits get pushed. Unreachable don't. (In case of plain git push, you are probably using the default configuration option push.default=upstream, which pushes the current branch; e.g. if you are on master, git push would push master, and all objects reachable from master.) A related term is "dangling object" - an object unreachable from any other object.

  2. git reflog expire deletes unreachable objects. After that, those reflogs are not unreachable, they are non-existent.

  3. Make them reachable (e.g. by branch or tag commands). Alternately, use the refspec parameter in your git push to explicitly select the object. (Every object is, by definition, reachable from itself.)

Related