Search code examples
gitgit-rebasegit-pull

git pull --rebase for a specific folder/file


I only want to rebase one folder.

Is it possible to do something like

git pull --rebase origin/master path/to/folder/or/file.txt

and only that path will be updated?


Solution

  • The quick answer is "no".

    The longer answer depends on what you are trying to accomplish, and whether or not you have any changes to any of the files/folders you want to rebase, and what if any history you are interested in showing.

    If you have no changes on your branch, and you just want to grab the latest file from origin/master and put it in your working directory, and you don't want there to be any 'history' of what happened, then you could do

    git fetch origin master
    git checkout origin/master -- path/to/file.txt 
    

    For anything more complicated than that it gets ugly fast.