For my future projects, I plan to do a combination of Arduino and RPi development. The development of the Arduino code will be on my MS Windows PC and the RPi solution will be developed naively within the RPi Linux environment Given this distributed environment (and my ability to bungle things), I can foresee potential problems maintain good source code control. To deal with this, the combination of git and gethub seems the right way to proceed .... after all it has worked for the distributed Linux development community.
Git on MS Windows
The first thing I did was to set up git within my MS Windows PC. Given that I installed Cygwin when setting up the RPi, that is where I returned to install git. Therefore, I plan to use git within the Cygwin environment on my PC and not within MS Windows per say. This could be done, but my approach allows me to learn git commands once since, Cygwin is a Linux-like environment, everything should look and operate the same.To accomplish this I follow the instructions outline in Installing Git on Cygwin. These instructions are very straight forward. The challenge was in initializing git for my first project, at least it was a challenge for me since git is new tool for me and Cygwin didn't always cooperate. I had to address this the old fashion way .... read the documentation and trouble logs (vs. doing a web search for someones web post with instructions). All the important secrets of git can be found widely dispersed and buried deep withing these web sites: Git Documentation and Git Reference. Source information from trouble logs will be listed below.
So how did I do it? It's easy once you successively done it once. First let me state the context; for the exercise I'm doing, I'm attempting to place my .bashrc, .profile, .vimrc
, and a few other configuration files under gits control. The basic sequence of operation is to initialize the git environment, configure some parameters, and then add the files. It goes like this (I'll let you research the git documentation, just like I did, to understand the command. Trust me, this is good for you!):
git init git config --global user.name "jeffskinnerbox" git config --global user.email [email protected] git config --global core.editor vim git config --global merge.tool vimdiff git add .bashrc .profile .vimrc .bash_profile .minttyrc .inputrc .gitconfig .gitignore
To see what you got, use the git status
command. This will tell you the files got staged but not committed. The commit will come later. First we need to set up our communal repository within github.
Setting Up GitHub
You may be asking, What Exactly Is GitHub Anyway? Well, in a few words, github is a web-based hosting service for software development projects that use git. The next step is to go to github, set up your free login, and then set up a repository. In my case, I set up a github repository called Cygwin-Configuration-Files to store my configuration files established earlier under git control. It will be empty at this point, and that's all for now, loading it with files comes later.I didn't say much about how to set up github, but trust me, it is as simple as outlined above. It's via git that all the real work takes place. GitHub is all about giving you an off-site, web-access-able, complete version controlled historical record of your code that can be shared with others.
Back to Git within Cygwin
Now that we have established github and initialized, configured, and added files to the Cygwin environment we can associated the PC and github environments. It wasn't clear to me, from the git documentation, how to best do this association. Usinggit clone
isn't intuitive to me, but it seems to work. This is how I did it:
git clone https://github.com/jeffskinnerbox/Cygwin-Configuration-Files.git
Warning ... You may, as I did, get the following error:
Cloning into 'Cygwin-Configuration-Files'... error: error setting certificate verify locations: CAfile: /usr/ssl/certs/ca-bundle.crt CApath: none while accessing https://github.com/jeffskinnerbox/Cygwin-Configuration-Files.git/info/refs fatal: HTTP request failed
If you get the above error, the problem is that Cygwin hasn't installed the ca-certificates package. Run the Cygwin installer again, and add that package; after that git clone
should start working.
The next step is to commit your files to the git local repository within the PC under Cygwin. To do this, execute the following command:
git commit
You will be put into vim to provide a comment that will be posted with the git version. Why vim? Because you executed the command git config --global core.editor vim
earlier. If you don't want to use vim for adding comments under git, supply another editor when you do the configuration step.
The next step, which strictly isn't required but a nice to have, is to associate a descriptive identifier with the github repository. The descriptor I used is "Cygwin-Configuration-Files". The command I used is:
git remote add Cygwin-Configuration-Files https://github.com/jeffskinnerbox/Cygwin-Configuration-Files.git
The final step is to push your local files to the github repository,
git push Cygwin-Configuration-Files
Warning ... It was during the git push
that I ran into another problem, but it could happen nearly any time. I discovered that sometimes, after multiple Cygwin updating or installing packages, you'll start to get strange errors related to "fork()" or .dll loading. After some research, I discoved these errors are usually solved by rebasing your packages. While rebasing, which is executed using the Cygwin rebaseall
command, is is a bit of a mystery, it does appear to work
Rebasing Cygwin
Before you can run therebaseall
command, you'll need to make sure no Cygwin-based services are running. To do this, you need to run two cygwin command, cygrunsrc and rebaseall, under the ash command in MS Windows command prompt, not in a Cygwin Terminal window. The sequence of activity is as follows:
- Exit the Cygwin Terminal
- Run as administrator the MS Windows Command Prompt window
- Execute ash via
\cygwin\bin\ash.exe
- Now under ash, see if any Cygwin processes are running via
/usr/bin/cygrunsrc -L
- Stop any of the running processes via
/usr/bin/cygrunsrc --stop <process's>
- Now do the rebase via
/usr/bin/rebaseall

Git on the Raspberry Pi
Admittedly, getting git setup under MS Windows / Cygwin isn't a walk in the park. It appears to work fine once set up, but the setup process can be painful.Git under the Raspberry Pi's Linux installs flawlessly, as you would expect, given git origins. First you install git via sudo apt-get install git
. Then, just as was done above, do the initialization of the git environment, configure some parameters, add the files, setup the github, clone, and push.
In my case, I setup a separate a github repository called RPI-Configuration-Files
to store my RPi configuration files. I could have used the same repository as was setup for the PC environment but that didn't make sense for my present needs.