Multiple working directories with Git?

Git 2.5 proposes since July 2015 a replacement for contrib/workdir/git-new-workdir: git worktree See commit 68a2e6a by Junio C Hamano (gitster). The release note mentions: A replacement for contrib/workdir/git-new-workdir that does not rely on symbolic links and make sharing of objects and refs safer by making the borrowee and borrowers aware of each other. See commit … Read more

.gitignore exclude folder but include specific subfolder

If you exclude application/, then everything under it will always be excluded (even if some later negative exclusion pattern (“unignore”) might match something under application/). To do what you want, you have to “unignore” every parent directory of anything that you want to “unignore”. Usually you end up writing rules for this situation in pairs: … Read more

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

How can I specify a branch/tag when adding a Git submodule?

I’d like to add an answer here that is really just a conglomerate of other answers, but I think it may be more complete. You know you have a Git submodule when you have these two things. Your .gitmodules has an entry like so: [submodule “SubmoduleTestRepo”] path = SubmoduleTestRepo url = https://github.com/jzaccone/SubmoduleTestRepo.git You have a … Read more

Can git automatically switch between spaces and tabs?

Here is the complete solution: In your repository, add a file .git/info/attributes which contains: *.py filter=tabspace Linux/Unix Now run the commands: git config –global filter.tabspace.smudge ‘unexpand –tabs=4 –first-only’ git config –global filter.tabspace.clean ‘expand –tabs=4 –initial’ OS X First install coreutils with brew: brew install coreutils Now run the commands: git config –global filter.tabspace.smudge ‘gunexpand –tabs=4 … Read more

How do you merge two Git repositories?

If you want to merge project-a into project-b: cd path/to/project-b git remote add project-a /path/to/project-a git fetch project-a –tags git merge –allow-unrelated-histories project-a/master # or whichever branch you want to merge git remote remove project-a Taken from: git merge different repositories? This method worked pretty well for me, it’s shorter and in my opinion a … Read more

Definition of “downstream” and “upstream”

In terms of source control, you’re downstream when you copy (clone, checkout, etc) from a repository. Information flowed “downstream” to you. When you make changes, you usually want to send them back “upstream” so they make it into that repository so that everyone pulling from the same source is working with all the same changes. … Read more