Github
Configuring credential.helper
On OS X (now macOS) run this in the Terminal:
git config --global credential.helper osxkeychain
Run ssh-add -K or ssh-add ~/.ssh/id_rsa to add the key to keychain again.
macOS 10.12 Sierra changes to ssh
For macOS 10.12 Sierra ssh-add -K needs to be run after every reboot. To avoid this create ~/.ssh/config with this content.
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
Adding an existing project to GitHub using the command line
git init
git add .
git commit -m "my instial commit"
git remote add origin [repository URL]
# Sets the new remote
git remote -v
# Verifies the new remote URL
git push -f origin master
Git reset after large file > 100Mb
git reset HEAD^ for as many commits you want to undo, it will keep your changes and your actual state of your files, just flushing the commits of them.
Change forked repo to new url
git remote set-url origin git://new.url.here
Preparing Git Repos for Public Release
I have a Git repo I'm about to release because Science. Unfortunately, its history is a bit messy and I don't necessarily want people to know about the embarrassing mistakes and backtracks I made, or the kind of time I put into the code.
#Rename master to old_master
git branch -m master old_master
#Find the most recent commit on old_master
git log
#Create, and switch to, a new master branch
git checkout --orphan master fb33e2286ffe90641f34c078a81a94e393dc30b8
#Commit the new master
git commit -m "Public release"
#Push up the branch, overwriting history:
git push --set-upstream origin master --force