Wątek przeniesiony 2015-03-16 00:50 z Nietuzinkowe tematy przez somekind.

Błąd przy push-u repozytorium na GitHub-ie

0

Witajcie,

Wczoraj zainstalowałem git na GNU/Linux. Mam projekt biblioteki, który chciałbym umieścić na GitHub (i może pokazać na forum jak poprawie parę błędów). Zrobiłem puste repozytorium na GitHub. Stworzyłem w folderze swoje repo. Dodałem pliki do śledzenia. Zrobiłem commita (lokalnie). Wygenerowałem klucz ssh i dodałem go do mojego konta GitHub. Dodałem zdalne repozytorium o nazwie tego co na GitHub (czyli CmdParser) i z adresem (?) SSH skopiowanym na GitHub. Wydałem polecenie git push CmdParser. Na GitHub nic się nie zmieniło. Dostałem takie coś w konsoli:

 
patryk@patryk-PC ~/Projekty/CmdParser $ git push CmdParser
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

To [email protected]:patrykbajos/CmdParser.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:patrykbajos/CmdParser.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.

Robiłem według tego poradnika: http://forum.android.com.pl/f999/jak-ua-ywaae-github-com-373809/

1

git push origin master spróbuj. Jak nie zadziała zrób cat .git/config i wklej co ci wypluło.

0

Zrobiłem.

patryk@patryk-PC ~/Projekty/CmdParser $ git push origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

patryk@patryk-PC ~/Projekty/CmdParser $ git push CmdParser master
To [email protected]:patrykbajos/CmdParser.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:patrykbajos/CmdParser.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.

patryk@patryk-PC ~/Projekty/CmdParser $ cat .git/config
[core]
	repositoryformatversion = 0
	filemode = true
	bare = false
	logallrefupdates = true
[remote "CmdParser"]
	url = [email protected]:patrykbajos/CmdParser.git
	fetch = +refs/heads/*:refs/remotes/CmdParser/*

patryk@patryk-PC ~/Projekty/CmdParser $ git remote
CmdParser
 
1

Ok, już łapie.

Zrób najpierw git pull bo najwidoczniej twoje zdalne repozytorium ma jakieś nowe pliki. Potem dopiero pushaj.

0

@n0name_l, nadal to samo. Jak zrobiłem wcześniej git pull CmdParser to git "nie oddał mi kontroli" nad konsolą, a otworzył mi plik w edytorze, żebym wpisał wiadomość (tak zrobiłem) i zapisałem. Czekałem to wyłączyłem konsole. W nowej konsoli napisałem git push CmdParser. Te same błędy. Może GitHub nie rozpoznaje mnie jako właściciela, albo coś z gałęziami (tam coś jest w logu)?

patryk@patryk-PC ~/Projekty/CmdParser $ git config -l
user.name=patrykbajos
user.email=_email_ukrył[email protected]
core.editor=geany
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
[email protected]:patrykbajos/CmdParser.git
remote.CmdParser.fetch=+refs/heads/*:refs/remotes/CmdParser/*

PS. Może w tym tutorialu z pierwszego posta jest źle wygenerowany klucz SSH?

1

A sprawdź jeszcze czy jak zrobisz po kolei w jakimś innym katalogu: git clone <remote_repo> cp -R <stary_katalog_z_repo> <nowy_katalog_z_repo> (bez katalogu .git) git add -A git commit -m ".." git push ... to zadziała.

Tj. sklonuj sobie repo do innego katalogu, przekopiuj pliki, dodaj je do stage, zcommituj i pushnij.

Sam log mówi tyle, że remote master ma dalej ustawiony pointer niż local master. Teoretycznie pull powinien to rozwiązać, tj. pobrać zmiany z remote master, po czym zmergewac pobrane zmiany do local master. Nie wiem czemu to nie działa. :\

1

po pierwsze pokaż co ci wypluwa:

git remote -v

Bo z błędu wynika, że tam jest coś źle ustawione, względnie źle piszesz komendę git-a. Ja bym oczekiwał origin zamiast CmdParser.

0

@n0name_l, teraz już zadziałało. http://pastebin.com/E2zVPpEP Czyli, że w tym starym repo usunąć mam .git i .gitignore i zrobić resztę jak z tym nowym i koniec?

PS. @MarekR22

patryk@patryk-PC ~/CmdParserHutHub $ git remote -v
CmdParser	[email protected]:patrykbajos/CmdParser.git (fetch)
CmdParser	[email protected]:patrykbajos/CmdParser.git (push)
origin	https://github.com/patrykbajos/CmdParser.git (fetch)
origin	https://github.com/patrykbajos/CmdParser.git (push)
1

@bajos No tak chyba najprościej będzie (tj. .gitignore nie musisz usuwać bo on nie ma związku wielkiego z repo). + Mógłbyś sobie ustawic push.default by tego brzydkiego warninga się pozbyć.

0
n0name_l napisał(a):

Ok, już łapie.

Zrób najpierw git pull bo najwidoczniej twoje zdalne repozytorium ma jakieś nowe pliki. Potem dopiero pushaj.

Jak ktoś wrzucił konfliktujące zmiany do repozytorium zdalnego, a nie wypychałeś wcześniej swoich zmian, to powinno się zrobić git fetch i git rebase origin/master, a nie pullować. Taki odwrotny pull później strasznie rozwala rebase'owanie / bisecting, zaśmieca historię i utrudnia analizowanie co faktycznie było zmieniane.

Ale tak czy inaczej, robisz to źle, bo powinieneś pracować na swoim prywatnym topic-branchu, a nie na gałęzi głównej. Jak topic branch jest gotowy, to robisz rebase względem mastera a później merge do master (zielony guzik na githubie, albo git merge <twoja gałąź> z poziomu mastera).

0

to powinno się zrobić git fetch i git rebase origin/master

Dokładnie to robi pull.

1

Prawda jest taka, że nigdy nie powinno się pracować na branchu master, ale na własnym branchu, a po wykonaniu zadania zrobić merge/rebase/commit tych zmian do master.

0

Dodałem zmiany do kodu. Zrobiłem gałąź. Ustawiłem gałąź na tą nową. Chcę zrobić git commit -m "Tutaj wpisalem komentarz" i dostaje błędy. Może przez ustawienie git config --global push.default simple tak jak w błędzie pisało.

patryk@patryk-PC ~/Projekty/CmdParser $ git branch komentarze
patryk@patryk-PC ~/Projekty/CmdParser $ git checkout komentarze
Switched to branch 'komentarze'
patryk@patryk-PC ~/Projekty/CmdParser $ git commit -m "Comments"
On branch komentarze
nothing to commit, working directory clean
patryk@patryk-PC ~/Projekty/CmdParser $ git add -A
patryk@patryk-PC ~/Projekty/CmdParser $ git commit -m "Comments"
On branch komentarze
nothing to commit, working directory clean
0

Nie zrobiłeś żadnych zmian, więc nie ma co commitować.

Zrób jakieś echo blabla > nowy_pliczek.txt, a potem commituj.

0

A dodawanie plików po jednym Ci działa? Co Ci pokazuje git status?

0
Krolik napisał(a):
n0name_l napisał(a):

Ale tak czy inaczej, robisz to źle, bo powinieneś pracować na swoim prywatnym topic-branchu, a nie na gałęzi głównej. Jak topic branch jest gotowy, to robisz rebase względem mastera a później merge do master (zielony guzik na githubie, albo git merge <twoja gałąź> z poziomu mastera).

Oj tam oj tam u nas w firmie to wszyscy pushują sobie od razu do mastera radośnie i nikt tam się w branche nie bawi. Serwer produkcyjny sobie pulluje też z mastera, w cronie, a jak ktoś tam wlezie i zmieni coś lokalnie to panika wybucha bo przestaje pullować i nikt nie wie jak to naprawić.

1 użytkowników online, w tym zalogowanych: 0, gości: 1