Git submodule update

This GitPro page does summarize the consequence of a git submodule update nicely When you run git submodule update, it checks out the specific version of the project, but not within a branch. This is called having a detached head — it means the HEAD file points directly to a commit, not to a symbolic … Read more

Squash my last X commits together using Git

Use git rebase -i <after-this-commit> and replace “pick” on the second and subsequent commits with “squash” or “fixup”, as described in the manual. In this example, <after-this-commit> is either the SHA1 hash or the relative location from the HEAD of the current branch from which commits are analyzed for the rebase command. For example, if … Read more

How to remove local (untracked) files from the current Git working tree

git-clean – Remove untracked files from the working tree Synopsis Description Cleans the working tree by recursively removing files that are not under version control, starting from the current directory. Normally, only files unknown to Git are removed, but if the -x option is specified, ignored files are also removed. This can, for example, be … Read more

How can I switch to another branch in git?

If another_branch already exists locally and you are not on this branch, then git checkout another_branch switches to the branch. If another_branch does not exist but origin/another_branch does, then git checkout another_branch is equivalent to git checkout -b another_branch origin/another_branch; git branch -u origin/another_branch. That’s to create another_branch from origin/another_branch and set origin/another_branch as the … Read more