There is a repository with code.
I want to store some directories and files in the repository, but so that their changes are not reflected in the development history.
For example, there is a catalog .vscode
with VS Code settings and a file with notes my_notes.txt
, and I want to be able to access them from different computers.
How can I make sure that the specified directories and files are saved in the repository (preferably with the history of changes), but so that their history is not mixed with the history of code development and at the same time they are available in this repository?
For example, I changed the my_notes.txt
on one computer and then made a commit:
git commit my_notes.txt <some_magic>
git push <some_magic>
After that I want to get this file on another computer:
git pull <some_magic>
Perhaps orphaned branches are suitable for this, but I could not find how to do so I want.
If I do so:
echo my_notes.txt >> .gitignore
git add .gitignore
git commit -m 'update gitignore'
git checkout --orphan orhf-branch
git rm -r --cached .
rm -rf *
echo 'some text' > my_notes.txt
git add .
git commit -m 'Orphan commit'
git checkout master
then file my_notes.txt
disappears from the master branch.
Is it possible to make the file my_notes.txt
was present when I switch to the master
branch, but the history of its changes was saved in the orhf-branch
?
And so that I can change it in the master
branch, but it doesn't show up as changed or untracked in master
?