Updated version: https://hsph.me/git
Because sometimes reseting the stach on the orgin of the local branch is confusing me :-)
Update local branch without loosing local commits and to prevent merge commits ( Merge branch 'master' into )
git pull --rebase origin master
- Get a nice list of commits
git log --oneline origin/master..<branchname> - Interactive rebase
git rebase -i <commitid> (or git rebase -i origin/master) - Follow prompts (squash to merge all commits together) then Esc+wq
- Force (because we rewrite history) push to branch
git push -f origin <branchname>
- go to the right folder
git submodule add [email protected]:REPO.git(SSH URL)
- (optionnal but recommanded) Make sure your repo is set with a SSH URL ([email protected]:REPO.git)
- (optionnal but recommanded)
git fetch origin - (optionnal but recommanded if this is not a brand new repo)
git rebase origin/master git branch BRANCHNAMEgit reset --hard origin/master(Use with care - make sure "git status" is clean and you're still on master)
git submodule update --init --recursive
git clone --recursive git@github:me/name.git .
- Delete the relevant section from the
.gitmodulesfile (usually 3 lines). - Stage the changes
git add .gitmodules. - Delete the relevant section from
.git/config(usually 2 lines). - Run
git rm --cached <path_to_submodule>(no trailing slash). - Run
rm -rf .git/modules/<path_to_submodule> - Commit
git commit -m "<commit_message>" - Delete the now untracked submodule files
rm -rf <path_to_submodule>
git clean -xfdgit submodule foreach --recursive git clean -xfdgit reset --hardgit submodule foreach --recursive git reset --hardgit submodule update --init --recursive