I find it most convenient to track a single file in a repository stored in a separate directory.
Make directory to store git repository
mkdir my-repo-path
Go to the worktree directory (where the file is located)
cd my-worktree-path
Initiate a separate repository inside the hidden .git my-repo-path subdirectory
git init --separate-git-dir my-repo-path\.git
Along with a separate repository, git created a hidden .git file in the worktree directory. You can delete it if you want (it can be useful if you are going to track some other files in the worktree directory separately in some separate storage (s)).
del /AH .git
In any text editor, open the file my-repo-path\.git\info\exclude and add the following lines to the end (where foo.txt is the file you want to track):
* !foo.txt
At a command prompt, go to the git repository and add what will be done.
cd my-repo-path\.git git add . git commit
Add a remote start and click the leading branch, adding a link up (tracking) to it.
git remote add origin <url> git push -u origin master
After that, you will add the following commits from your git repo directory (see from the second to the last step).
quicktrick
source share