I'm new with git and I'm trying to use JGit in a java application. I would like to know if Git has a 'commmit of files into a specific directory' or is Git only based on the working tree where files are stored?
For example, let's say I have a file saved in C:/tmp/myfile.docx. Is it possible to tell Git to store it in the repository as /myProject/myfile.docx ?
Thank you :)
That is not possible. Think of your Git repository as a time machine for a tree of directories. You can only add files to git that are inside that directory tree. And don't try to make C:\ a Git repository... :)
So, let's say your Git repository resides at C:\tmp\myRepo
. To add your file to the repository you'd do this:
myfile.docx
to C:\tmp\myRepo
cd C:/tmp/myRepo && git add -A
git commit -am "added myfile.docx"