It is possible to copy a file from one branch to another without the destination being committed, for example:
$ git checkout otherbranch somefile
$ git reset HEAD somefile
However, can the above be done with a single git command?
It is possible to copy a file from one branch to another without the destination being committed, for example:
$ git checkout otherbranch somefile
$ git reset HEAD somefile
However, can the above be done with a single git command?
git cat-file --filters -p otherbranch:somefile > somefile
otherbranch:somefile refers to the blob of somefile on otherbranch.
git cat-file -p prints the content of the blob.
> somefile overwrites somefile in the worktree with the content.
As @jthill commented, --filters should be used in case any filter is configured and somefile is affected. git lfs is one of the use cases.