2022-11-29
Set up
git config --global user.name "Your Name"
git config --global user.email "Your Email"Start a repository
git initStage changes for commit
git add -A .Commit with message
git commit -m "commit message"Add remote origin (new repository on github)
git remote add origin git@github.com/repository-namePush to new github repository
git push origin -U masterSometimes you might want to use a different ssh key to access git than the default one. For example, you're using your personal computer to work from home and need to log in with your work github account. (Make sure your work's security team allows this!)
From this really great StackOverflow answer.
Clone a repository with a different ssh key
git clone -c core.sshCommand="/usr/bin/ssh -i /home/me/.ssh/id_rsa_foo" git@github.com:me/repo.gitSet a repository to always use an alternate ssh key
git config --local core.sshCommand "/usr/bin/ssh -i /home/me/.ssh/id_rsa_foo"See the docs for complete information about using submodules.
Clone with submodules
git clone --recurse-submodules https://github.com/somebody/MainProjectPull upstream changes and update submodules
git pull origin branch-name
git submodule update --init --recursiveAlternately:
git pull --recurse-submodules origin branch-nameFrom StackOverflow
Merge changes to a new branch, then merge to master.
git remote add upstream https://github.com/parent/repository.git
git checkout -b parent-updates
git fetch upstream
git merge upstream/master
# fix merge errors
git checkout master
git merge parent-updates
git push origin master