GIT: (bestes) Vorgehen, wenn push fehlschlägt

vup

Mitglied
Wer kennt's nicht, man hat sich viel Mühe gegeben, und möchte man seine bereits committeten Änderungen in den Feature-Branch pushen. Es gibt aber ein Problem: Es gab zwischenzeitlich im selben Branch eine Änderung, zum Beispiel durch Kollegen oder die Pipeline ...

In solchen Fällen tue ich Folgendes:

Bash:
git reset --soft HEAD~1
git stash
git pull
git stash pop
<... merge Konflikte lösen ...>
git add
git commit -m "Meine tolle Änderung..."
git push

Ist dieses Vorgehen so richtig, insbesondere das reset ...? Wie macht man es richtig?
 

vup

Mitglied
Danke, nützlicher Tipp, meine config sieht inzwischen so aus:

Code:
[push]
    autoSetupRemote = true
[alias]
    lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n''          %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
[pull]
    rebase = true
[fetch]
    prune = false
[rebase]
    autoStash = true
    autosquash = false
    updateRefs = false
[diff]
    guitool = vscode
[difftool "vscode"]
    ...
 

vup

Mitglied
Ich konfiguriere mir global immer autostash und pull-rebase, wie hier angegeben

gerade ausprobiert, es funktioniert!!!, ich (schusselig) habe ein push gemacht, der rejected wurde, anschließend musste ich einfach nur einmal pull und push aufrufen :) :

Code:
PS C:\Users\\Downloads\programming1\> git push
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 1.22 KiB | 624.00 KiB/s, done.
Total 6 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com//
   1f86659..da98d70  1.2 -> 1.2
PS C:\Users\\Downloads\programming1\> git push
To https://github.com//
 ! [rejected]        1.2 -> 1.2 (fetch first)
error: failed to push some refs to 'https://github.com//'
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.
PS C:\Users\\Downloads\programming1\> git pull
remote: Enumerating objects: 11, done.
remote: Counting objects: 100% (11/11), done.
remote: Compressing objects: 100% (1/1), done.
remote: Total 6 (delta 2), reused 6 (delta 2), pack-reused 0
Unpacking objects: 100% (6/6), 787 bytes | 21.00 KiB/s, done.
From https://github.com//
   aa98d70..ff7c72f  1.2        -> origin/1.2
Successfully rebased and updated refs/heads/1.2.
PS C:\Users\\Downloads\programming1\> git push
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (6/6), 445 bytes | 222.00 KiB/s, done.
Total 6 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com//
   ff7c72f..55bc569  1.2 -> 1.2

PS: Sensible Angaben (Benutzername, CommitID...) hab ich geändert, wollte nur zeigen, dass es funktioniert.
 

Ähnliche Java Themen

Neue Themen


Oben