Невозможно отправить коммит во вновь созданный репозиторий на GitHub - PullRequest
0 голосов
/ 13 сентября 2018

Я недавно только что создал новый репозиторий на GitHub (только для меня) в моей учетной записи. Используя командную строку, я перешел к папке, содержащей некоторые файлы и папки, которые я хочу отправить в онлайн-хранилище с помощью командной строки. Я онлайн-репозиторий просто включает в себя первоначальный коммит и один файл readme. Я использовал git add --all, чтобы добавить все внутри папки и используя текущий каталог в качестве мастера. У меня все еще возникают проблемы при нажатии.

Я пытался использовать fetch, pull, merge, rebase, затем push снова, но это не работает. Вот часть того, что я сделал:

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git push -u origin master
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
Username for 'https://github.com': Muaz.Al.Jarhi@Gmail.com
To https://github.com/SamuraiHub/Java.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/SamuraiHub/Java.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
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.

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ ^C

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git fetch origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/SamuraiHub/Java
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
Counting objects: 6350, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (6164/6164), done.
Writing objects: 100% (6350/6350), done.
Total 6350 (delta 534), reused 0 (delta 0)
Removing duplicate objects: 100% (256/256), done.

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git merge origin master
merge: origin - not something we can merge

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git push -u origin master
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
Username for 'https://github.com': Muaz.Al.Jarhi@Gmail.com
To https://github.com/SamuraiHub/Java.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/SamuraiHub/Java.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master


Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git checkout master
Already on 'master'

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master


Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git push -u origin master
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
Username for 'https://github.com': Muaz.Al.Jarhi@Gmail.com
To https://github.com/SamuraiHub/Java.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/SamuraiHub/Java.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git pull --rebase
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master


Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git fetch origin master
From https://github.com/SamuraiHub/Java
 * branch            master     -> FETCH_HEAD

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git merge origin master
merge: origin - not something we can merge

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git merge master
Already up-to-date.

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git push -u origin master
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
Username for 'https://github.com': Muaz.Al.Jarhi@Gmail.com
To https://github.com/SamuraiHub/Java.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/SamuraiHub/Java.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ ^C

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git pull --rebase
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master


Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master


Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master)
$ git pull origin master --rebase
From https://github.com/SamuraiHub/Java
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...



Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java ((ec222e4...)|AM/REBASE)
$

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java ((ec222e4...)|AM/REBASE)
$ git push -u origin master
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
Username for 'https://github.com': Muaz.Al.Jarhi@Gmail.com
To https://github.com/SamuraiHub/Java.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/SamuraiHub/Java.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and 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.

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java ((ec222e4...)|AM/REBASE)
$ git checkout master
Checking out files: 100% (10551/10551), done.
Previous HEAD position was ec222e4... Initial commit
Switched to branch 'master'

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master|AM/REBASE)
$ git push -u origin master
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
Username for 'https://github.com': Muaz.Al.Jarhi@Gmail.com
To https://github.com/SamuraiHub/Java.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/SamuraiHub/Java.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Muaz Aljarhi@MuazAljarhi-PC MINGW64 /f/muaz/Programming/Java (master|AM/REBASE)
$

Любые идеи о том, как это исправить, кроме загрузки с веб-сайта и использования опции --force или -f (я знаю, что это может не вызывать проблем здесь, но обычно мы не должны использовать это)?

1 Ответ

0 голосов
/ 13 сентября 2018

онлайн-репозиторий включает в себя только начальную фиксацию и один файл readme

Это ваша проблема.Ваша локальная копия не содержит этого коммита.

Я бы, вероятно, исправил бы его, добавив удаленный, получив origin/master, перебазировав (не объединяя) мою локальную работу сверху, а затем нажав:

git remote add origin <url>
git fetch origin
git checkout master
git rebase origin/master
git push

Конечно, если вы предпочитаете объединяться, это тоже хорошо.Но у вас есть синтаксическая ошибка:

$ git merge origin master
merge: origin - not something we can merge

Вам необходимо объединить origin/master (один аргумент, называющий ссылку на удаленное отслеживание), а не origin master(два аргумента).

Ваш git pull не выполнен, поскольку нет информации для отслеживания для master:

$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

Git не знает, к какой удаленной ветви перейтиизвлекать и объединяться с вашим локальным master, но вы можете сказать это с помощью git branch --set-upstream-to, как следует из сообщения об ошибке.

Пожалуйста, обязательно прочитайте сообщения об ошибках, которые предоставляет Git.Они могут быть немного плотными, но они содержат полезную информацию.

Любые идеи о том, как это исправить, кроме загрузки с веб-сайта и использования опции --force или -f (я знаю,это может не вызывать проблем здесь, но обычно мы не должны его использовать)?

В этом случае, если вы не хотите README, созданный GitHub, я не вижу никакого вреда в принудительном толкании(хотя я бы порекомендовал сначала извлечь и использовать --force-with-lease, что с меньшей вероятностью позволит вам сделать коммит, которого вы не знаете).

...