Git Notes
Table of Contents
Resources
- Roger Rudler: git-guide
- Pro Git book
- Oh Shit, Git!?!
- w3schools: git tutorial (Has a cool teach yourself with exercises section)
- Git from the Bottom Up
Change remote URL
git remote set-url <REMOTE_NAME> <REMOTE_URL>
Rename branch
- If current branch
git branch -m new-name
- If not current branch
git -m old-name new-name
Submodules
Adding a submodule
git submodule add <GIT_REPO>
Pull submodules
git submodule update --init --recursive
Updating submodule remote
git submodule set-url -- <PATH> <URL>
Delete Remote Branch
git push <REMOTE> --delete <BRANCH>
Magit
Resources
Checking out a file from another branch
- From within the
magit
menu pressX
forReset
commands - From inside the
Reset
commands list pressf
forFile
- Next pick the source branch, then pick the file in the repo
- This will revert that file in the current branch to the version from the other branch as a soft change
View file from another branch
git show <BRANCH>:<file>
- For example
git show main:.gitignore
to view the version of the gitignore from the main branch