Git Notes
<2023-08-11 Fri>
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
Checking out a file from another branch
- From within the
magit menu press X for Reset commands
- From inside the
Reset commands list press f for File
- 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