How can I move HEAD back to a previous location? (Detached head) & Undo commits

Before answering, let’s add some background, explaining what this HEAD is. First of all what is HEAD? HEAD is simply a reference to the current commit (latest) on the current branch. There can only be a single HEAD at any given time (excluding git worktree). The content of HEAD is stored inside .git/HEAD and it … Read more

How do I add files in Git to the path of a former submodule?

Git still think mysubmodule is a submodule, because it is recorded in the index with a special mode “160000”. See “git submodule update needed only initially?” for more. To check that, as in in this answer, you can do a: $ git ls-tree HEAD mysubmodule 160000 commit c0f065504bb0e8cfa2b107e975bb9dc5a34b0398 mysubmodule That doesn’t depend on the presence … Read more

How to remove/delete a large file from commit history in the Git repository?

Use the BFG Repo-Cleaner, a simpler, faster alternative to git-filter-branch specifically designed for removing unwanted files from Git history. Carefully follow the usage instructions, the core part is just this: $ java -jar bfg.jar –strip-blobs-bigger-than 100M my-repo.git Any files over 100MB in size (that aren’t in your latest commit) will be removed from your Git … Read more