2013-02-11 1 views
3

Пытается использовать поддеревье git для совместного использования общих файлов библиотеки в нескольких проектах. Вот проблема, с которой я сталкиваюсь.Git subtree push всегда сбой

1) Добавить поддерево, поэтому подкаталог «lib» моего проекта поступает из репозитория lib-dk.

$ git subtree add --prefix=lib --squash [email protected]:dwknight/lib-dk.git master 

2) Внесение изменений в файлы "Lib"

3) вносить изменения в основной проекта репо

$ git commit -am "update project" 

4) нажать обновления основного проекта репо

$ git push origin master 

5) нажать изменения в «lib» обратно на «lib-dk» репо

$ git subtree push --prefix=lib [email protected]:dwknight/lib-dk.git master 
git push using: [email protected]:dwknight/lib-dk.git master 
To [email protected]:dwknight/lib-dk.git 
! [rejected]  f455c24a79447c6e3fe1690f5709357b7f96828a -> master (non-fast-forward) 
error: failed to push some refs to '[email protected]:dwknight/lib-dk.git' 
hint: Updates were rejected because the tip of your current branch is behind its remote counterpart. Merge the remote changes (e.g. 'git pull') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

6) Я получаю это отклонение, даже если в реплике lib-dk ничего не изменилось. Когда я пытаюсь вытащить, он действует как что-то, но я могу обновить его. Тем не менее настойчивость продолжает отвергаться.

+1

У меня нет опыта использования команды 'поддерево', но операция' '' '' '' '' '' '' 'выглядит как опция' rebase'. Что оно делает? Если он каким-то образом изменяет историю ветвей, это может вызвать эту проблему. – asm

ответ

2

Когда я пробую это без опции --squash до git subtree add, он работает. Я думаю, как сказал комментатор, --squash путается с историей бесполезным образом.

0

Вам может понадобиться использовать git add -A . затем git commit вместо git commit -am <message>

поскольку -A в git-add бы:

-A, --all, --no-ignore-removal 
     Update the index not only where the working tree has a file matching <pathspec> but also where the 
     index already has an entry. This adds, modifies, and removes index entries to match the working 
     tree. 

     If no <pathspec> is given when -A option is used, all files in the entire working tree are updated 
     (old versions of Git used to limit the update to the current directory and its subdirectories). 

с другой стороны, -a в git-commit бы (не так много деталей задается страница руководства):

-a, --all 
     Tell the command to automatically stage files that have been modified and deleted, but new files 
     you have not told Git about are not affected. 

this может быть полезно. Автор явно указал git add -A ..