Last Updated on March 13, 2023.
This is a cheat sheet – it’s not necessarily cohesive, complete, or meant for straightforward consumption. It’s primarily for me to remember bits and pieces I won’t work with everyday, so I can come back to them later and get back up to speed.
This initially started when I wanted to take the SVN source of the VICE Commodore Emulator and put it in Github so I could easily share patches I’ve made for those interested in my Commodore 64 Diorama project, which patches VICE so I could detect 1541 disk drive activity.
I’m not a Git expert at all – this was just to get something going. My major concerns were CR/LF line feeds when editing on Linux vs Windows.
Initial Config of Git Client
This should (as I’m not using SSH yet), be the private email setup on my account’s https://github.com/settings/emails page.
git config --global user.name "Harry Potter"
git config --global user.email "git commit email"
git config --global core.editor vi
Using a created repo of mine from Github
I created a repo for VICE and my related patches at https://github.com/erkrystof/vice and populated with the standard README setup.
Now I need to clone it down to my Pi:
clone https://github.com/erkrystof/vice.git
.gitattributes for the line feeds
Created a .gitattributes file in the root with the following:
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary
Reference:
https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings
https://adaptivepatchwork.com/2012/03/01/mind-the-end-of-your-line/
Rebasing if necessary
I had to do this when I originally setup my local repo on the raspberry pi with my account email, and not my commit email, so to reset that accordingly (should be one time unless I goof it up again)
git config --global user.email "GITCOMMIT-EMAIL"
git rebase -i
git commit --amend --reset-author
git rebase --continue
git push
Adding VICE and committing
I checked out VICE from SVN, removed the .SVN metadata directory, copied it over into my repo I checked out and did an add and commit.
git add --all
git commit -am "<commit message>"
git push
Cloning again, switching the branch
When I want to bring it down again, or switch to a branch to compile, I’ve been doing this:
git clone https://github.com/erkrystof/vice.git
#This is the branch based of VICE 3.4 that contains my circuit / shared memory modifications.
git checkout 3.4-Diorama-Mods
Updating VICE trunk / tags into GIT
I haven’t had to do this yet, so I’ll have to come back to it. As VICE is updated, I want to update my 3.4 trunk, but also keep my patches aligned. That will be more advanced then my simple stuff, so a good learning experience I look forward to.
Removing GIT history without a new repo
(Assumes no forks, tags, etc.)
git checkout --orphan newBranch
git add -A # Add all files and commit them
git commit
git branch -D main # Deletes the master branch
git branch -m main # Rename the current branch to master
git push -f origin main # Force push master branch to github
git gc --aggressive --prune=all # remove the old files