Complex git operations and commands that I always forget...
- Remove Submodule
- Subtree Merging
- Delete a Remote Branch
- Change Timestamp of the Last Commit
- Squash Commits
- Migrate SVN to git
- Export project
- Pull after Forced Push
- Delete the relevant section from the
.gitmodulesfile. git add .gitmodules- Delete the relevant section from
.git/config. git rm --cached <path_to_submodule>(no trailing slash).rm -rf .git/modules/<path_to_submodule>git commit -m "Removed submodule <name>"- Delete the now untracked submodule files
rm -rf <path_to_submodule>
git remote add <subtree-merge-repo-name> <url>git fetch <subtree-merge-repo-name>git checkout -b <some_new_branch> <subtree-merge-repo-name>/<branch>git checkout mastergit read-tree --prefix=<subfolder>/ -u <some_new_branch>git merge --squash -s subtree --no-commit <some_new_branch>
- remove local branch from your machine:
git branch -d the_local_branch - remove a remote branch:
git push origin :the_remote_branch
git commit --amend --date="$(date -R)"
- You are on
<branch1>and want to squash and merge commits from<branch2>:git merge --squash <branch2> - You are on
<branch2>and want to rebase on<branch1>and squash commits from on top:git rebase -i <branch1>
git archive master | tar -x -C ~/target
git fetch
git reset <remote>/<branch> --hard