LINUX.ORG.RU

История изменений

Исправление byko3y, (текущая версия) :

Сразу второй тур запощу:

$ git push ../test
To ../test
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '../test'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushin
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Начало не предвещает беды.

$ git pull ../test
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../test
 * branch            HEAD       -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
        Makefile
Please commit your changes or stash them before you merge.
Aborting

Что тут у нас? Но я не хочу вносить эти локальные правки из Makefile в общую репу. Мне можно, конечно, вручную сделать резервную копию моих файлов — однако, в таком случае я предпочту выкинуть Git и распространять исходники в тарболах, потому что трудоемкость примерно сравнимая. Но я все-таки предпочел использовать git — хорошо, будем через stash всё делать. Окей, гуглим руководства по использованию stash, которое снова не входит в золотой набор «checkout, commit, push».

$ git stash
Saved working directory and index state WIP on master: 4dbc60c Merge ../test

$ git pull ../test
From ../test
 * branch            HEAD       -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
$ git stash pop
Auto-merging Makefile
CONFLICT (content): Merge conflict in Makefile
The stash entry is kept in case you need it again.

$ git mergetool
Merging:
Makefile

Normal merge conflict for 'Makefile':
  {local}: modified file
  {remote}: modified file
...

Здесь я смухлевал, потому что я использовал еще и «git status», иначе я бы запушил в репу черт пойми что:

$ git status
On branch master
Your branch is ahead of 'origin/master' by 9 commits.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   Makefile

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        Makefile.orig

$ git reset Makefile
Unstaged changes after reset:
M       Makefile

Ой, я же забыл запушить:

$ git stash
Saved working directory and index state WIP on master: d2b176a Merge ../test

$ git push ../test
Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 2 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (9/9), 987 bytes | 493.00 KiB/s, done.
Total 9 (delta 1), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ../test
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '../test'

Опача. Вот и приехали. А оба репозитория чисты, тем временем.

Исходная версия byko3y, :

Сразу второй тур запощу:

$ git push ../test
To ../test
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '../test'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushin
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Начало не предвещает беды.

$ git pull ../test
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ../test
 * branch            HEAD       -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
        Makefile
Please commit your changes or stash them before you merge.
Aborting

Что тут у нас? Но я не хочу вносить эти локальные правки из Makefile в общую репу. Мне можно, конечно, вручную сделать резервную копию моих файлов — однако, в таком случае я предпочту выкинуть Git и распространять исходники в тарболах, потому что трудоемкость примерно сравнимая. Но я все-таки предпочел использовать git — хорошо, будем через stash всё делать. Окей, гуглим руководства по использованию stash, которое снова не входит в золотой набор «checkout, commit, push».

$ git stash
Saved working directory and index state WIP on master: 4dbc60c Merge ../test

User@admin-?? MINGW64 /g/etc/nodejs/test2 (master)
$ git pull ../test
From ../test
 * branch            HEAD       -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
$ git stash pop
Auto-merging Makefile
CONFLICT (content): Merge conflict in Makefile
The stash entry is kept in case you need it again.

$ git mergetool
Merging:
Makefile

Normal merge conflict for 'Makefile':
  {local}: modified file
  {remote}: modified file
...

Здесь я смухлевал, потому что я использовал еще и «git status», иначе я бы запушил в репу черт пойми что:

$ git status
On branch master
Your branch is ahead of 'origin/master' by 9 commits.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   Makefile

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        Makefile.orig

$ git reset Makefile
Unstaged changes after reset:
M       Makefile

Ой, я же забыл запушить:

$ git stash
Saved working directory and index state WIP on master: d2b176a Merge ../test

$ git push ../test
Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 2 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (9/9), 987 bytes | 493.00 KiB/s, done.
Total 9 (delta 1), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote:
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote:
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ../test
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '../test'

Опача. Вот и приехали. А оба репозитория чисты, тем временем.