All my slides and material that I use in class can be found on my GitHub site.
# Update the package list, update all packages and remove any packages that are no longer required on your Raspberry Pi
sudo apt-get update -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y
Creating a repository
-
First create a new repository:
echo "# sensehat" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin git@github.com:tarikgit/sensehat.git
git push -u origin master
-
Tell GitHub who you are:
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
-
Delete saved password on your computer
-
Creating a personal access token
-
Generate a new SSH key
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Press Enter to set a default file location. When asked to Enter passphrase …, provide a safe password.
-
Add new SSH key to your GitHub account
-
Copy the SSH key to your clipboard
-
Open id_rsa.pub:
cat ../.ssh/id_rsa.pub
# assuming that the current folder is /home/pi/sensehat
Copy the key and paste it into GitHub
-
Push your first commit
git commit -m "initial commit"
git push origin master
-
Putting all the commands into a sequence:
git add *
git commit -m "description of commit"
git push
-
If your Personal Access Token is expired follow this New personal access token.
-
If your password has expired, here is how you can update the cached password on Mac OS. A username and password prompt will appear with your next git action (push, clone, etc.).
git config --global credential.helper osxkeychain
-
Finally, here is a way to update all git repositories on a directory:
for i in */.git; do cd $(dirname $i); git pull; cd ..; done
Summary
-
Get changes on GitHub back to your computer
git pull origin master
-
Check all new commits
git log
-
Switch branches back to the master branch
git checkout master
-
Commit new changes
git add * git commit -m "write a short comment here" git push