0

I'm very new to using git, so I understand this may seem like a simple question or one that's been asked before, but I can't word it to get an answer. Anyway.

My thoughts are that I code on my laptop, at the minute when I want to put my program on a server, which happens to be the raspberry pi sitting under my desk, I simply SCP to it.

I was wondering how using git I can update files in a directory. For example all I need to run the bot is two files.

pi@raspberrypi:~/gitDiscordBot/Jarvis $ ls -a
.  ..  bot.py  .git  .gitignore  Insult.txt  README.md

This is the result from simply cloning the repo, however I don't need most of these files/directories. I don't need .git, .gitignore or README.mb. I also need to keep a credentials.json file in tact that isn't in the repo as it contains sensitive data accessed by bot.py.

What's the best way to make some sort of 'update' function that simply grabs the files bot.py and any other files that I need, in this case Insult.txt, replace the existing copies and keep credentials.json untouched, without other redundant git files.

I understand, this may not be the best approach, I'm looking to find the best approach, so please feel free to contradict what I'm saying, I don't know if keeping the git repo is a good thing for example. But all I simply need is the latest versions of bot.py and the other files in a directory so I can run them on my pi.

Such that

$ ls -a
. .. bot.py Insult.txt credentials.json

1 Answer 1

1

first of all, welcome to git!

.git and .gitignore files are for git to function. You cannot remove them. They are tiny in size and they are not "copied" when you do commit and sync. So, they should not be problem to your application.

For your sensitive file, credentials.json, you can put it into .gitignore file. This way, it won't be included in any commits. There will be only one copy of it in you machine.

This approach is good and works well. But, I think in your case you need rsync rather than git. From the official manuals page:

Rsync is a fast and extraordinarily versatile file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. It offers a large number of options that control every aspect of its behavior and permit very flexible specification of the set of files to be copied.

You can learn more about it here.

Hope this helps.