What's command to change the commit in the ".git\HEAD" file without changing any other files? I needed files from one branch, but the Head points to another
Asked
Active
Viewed 55 times
1
-
`git checkout THE_BRANCH`? I'm not quite sure if that answers what you want, because I'm not quite sure what you're asking. – Joachim Sauer Jan 11 '21 at 10:44
-
This command will not only change the HEAD, but also change the files of my project, which I don't need. – Ilya Jan 11 '21 at 10:47
-
1This smells like an [XY Problem](https://xyproblem.info). **Why** do you want to change `.git/HEAD`. What is your end goal? – Joachim Sauer Jan 11 '21 at 10:49
-
1What do you want to achieve with this? (XY problem flag rising) (hey @JoachimSauer seems we're synchronized :-) ) – Romain Valeri Jan 11 '21 at 10:49
-
Are you wanting to change branch, but keep file changes? – evolutionxbox Jan 11 '21 at 10:53
-
@RomainValeri I want to see what the result of merging one branch into another will be, but I don't want to do that merge yet. – Ilya Jan 11 '21 at 10:56
-
3@Ilya you can merge without committing. `git merge
--no-commit` – evolutionxbox Jan 11 '21 at 10:57
1 Answers
2
If you just want to check the outcome of a merge, you could just do the merge. If it is successful you can undo it with git reset HEAD^1
. If it fails with conflicts you can go back with git merge --abort
. Another possibility is doing a merge without commit as @evolutionxbox suggested (git merge <branch_name> --no-commit
).

EricSchaefer
- 25,272
- 21
- 67
- 103