GIT: go back to the old commit and merge that with the master

Given a project with two files: fileAand fileB. Both have been added to the git repository. Then I added fileAto .gitignore(and dropped git -cache), so it’s only fileBpresent in the current main . I would like to clone this repository to another computer, but fileA is missing.

The next thing I did was create a branch from a commit, in which both files were present. Now the big question is: how can I return to the master commit without losing this file again?

Sorry for the title. I tried to describe, but ..

+3
source share
2 answers

, git checkout:

$ git checkout <revision_where_fileA_exists> fileA
$ git add fileA
$ git commit -m "Restored fileA"

.gitignore, fileA.

+3

, Josh , , , , , ... , -f, , . git .

$ git checkout master
$ git pull -f . <branch>:master

, . :

$ git reset 
$ git revert

Reset , , , , , .

, . "" .

+3

Source: https://habr.com/ru/post/1734597/


All Articles