Asked  7 Months ago    Answers:  5   Viewed   46 times

I would like to rename/move a project subtree in Git moving it from




If I use a plain git mv project components, then all the commit history for the xyz project gets lost. Is there a way to move this such that the history is maintained?



Git detects renames rather than persisting the operation with the commit, so whether you use git mv or mv doesn't matter.

The log command takes a --follow argument that continues history before a rename operation, i.e., it searches for similar content using the heuristics:

To lookup the full history, use the following command:

git log --follow ./path/to/file
Tuesday, June 1, 2021
answered 7 Months ago

Looks like the following process had a lock on the .gitindex file:


I killed the process and ran git reset HEAD and looks like I'm back to normal now.

Thursday, June 17, 2021
answered 6 Months ago

This is not possible. If you have committed a file, then it will be pushed. The push action only acts on commits, not on a file basis.

But you could use a submodule for your sensitive data and keep this submodule on your local machine, while you push the regular git repository to the remote machine.

Sunday, August 1, 2021
answered 4 Months ago

As illustrated in this thread

Git doesn't care about individual files or renames, it tracks whole trees.
What it shows as a rename is just its best guess based on the contents of the two files.

Git status does perform rename detection using a heuristic.
But once you commit, you will see the two files are kept separate.

Thursday, August 5, 2021
answered 4 Months ago

GitHub uses the Linguist library for source code detection; Linguist treats all of the paths defined in its' vendor.yml as vendored and won't include them in the language statistics for a repository.

You can specify something different for your repo by editing your repo's .gitattributes file. To treat a path as a vendored file, add the path followed by linguist-vendored:

special-vendored-path/* linguist-vendored

To treat an otherwise vendored path as unvendored, use linguist-vendored=false:

jquery.js linguist-vendored=false


Wednesday, August 11, 2021
answered 4 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :