Tracking correct files in RStudio folder

git

#1

I think this is a fairly simple question. I've set up a new site using the blogdown package and thehugo academic theme. Everything is working great, but I am curious about the files that are being staged in RStudio.

So, currently the folder structure looks like this:

/website_folder/
-content
-public
-all other hugo files.

But, when I did the first commit to push my website to the github repository, RStudio committed files for almost all the other folders that are parallel to /website_folder/.

so it added
/Documents/.
/Desktop/.
/Applications/.

etc. etc.

I would like RStudio to only commit changes in website_folder/public/.

When I navigate to website_folder/public/ in the terminal and commit the changes there, then it only commits the the changes in the public folder.

So, how do I get RStudio to only commit changes made in file website_folder/public?
Do I have to make a .gitignore file in website_folder?

Thank you. I hope this question is clear.


#2

This is a git problem, you need to initialize version control in your projects working directory not in the parent directory and if you need finer control, then use .gitignore


#3

Because of this question, I learned the Git command to print a repository's root directory:

git rev-parse --show-toplevel

Stack Overflow should really be considered the official documentation for Git.


#4

Are you working using RStudio project ?
In your case, RStudio project should be at website_folder/ and the git repository also.

Working inside project and repository you should not see any of parent folder.