I have a script that checks out a branch to a temporary directory in order to compare it with the current work dir (e.g. using beyond compare). The temporary directory is deleted afterwards (i.e. does not affect the working dir unless I intentionally copy something over, for instance). The essential checkout command is:
git --work-tree="${TEMP_DIR}" checkout ${BRANCH} -- ${FILES}
$FILES may be . when I want all files.
Problem:
When the temporarily checked-out branch contains files that are not present in the working dir, the tracker detects them anyway, and next time I call git status
, I get a long list of files that are not-yet committed as "new" (green), but then at the same time as "not staged" / "deleted" (red).
When adding them with git add .
and commit, they are eventually ignored, but I would prefer that they were just ignored during the temporary checkout in the first place, so that git status
showed only changes in the actual work dir.
Is there any kind of "peek" checkout that just silently copies the content of a branch to somewhere, without affecting any status/tracker?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…