add gi
This commit is contained in:
parent
76f23f589c
commit
e2747d09dd
118
git/README.md
Normal file
118
git/README.md
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
---
|
||||||
|
gitea: none
|
||||||
|
include_toc: true
|
||||||
|
---
|
||||||
|
# Git
|
||||||
|
|
||||||
|
## delete branch
|
||||||
|
|
||||||
|
Lokal Branch löschen z.B. wenn er auf Origin in master gemergt wurde.
|
||||||
|
|
||||||
|
```
|
||||||
|
// delete branch locally
|
||||||
|
git branch -d localBranchName
|
||||||
|
|
||||||
|
// delete branch remotely
|
||||||
|
git push origin --delete remoteBranchName
|
||||||
|
```
|
||||||
|
|
||||||
|
## master updaten auf Stand von origin/master
|
||||||
|
|
||||||
|
```
|
||||||
|
git checkout master
|
||||||
|
git pull
|
||||||
|
git reset --hard origin/master
|
||||||
|
git pull
|
||||||
|
```
|
||||||
|
|
||||||
|
## Remote Branch als neuen local branch
|
||||||
|
|
||||||
|
```
|
||||||
|
git fetch origin
|
||||||
|
# Anzeigen aller Branches
|
||||||
|
git branch -a
|
||||||
|
# zuerst local dann origin-name angeben:
|
||||||
|
git checkout -b INITIATIVE-242_Ru origin/INITIATIVE-242_Ru
|
||||||
|
```
|
||||||
|
|
||||||
|
## Tag löschen
|
||||||
|
|
||||||
|
### Lokal
|
||||||
|
|
||||||
|
```
|
||||||
|
git tag -d tagname
|
||||||
|
```
|
||||||
|
|
||||||
|
### Remote
|
||||||
|
|
||||||
|
```
|
||||||
|
git push --delete origin tagname
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1 oder mehrere Commits zurück
|
||||||
|
|
||||||
|
### 1 Schritt zurück
|
||||||
|
|
||||||
|
```
|
||||||
|
git reset --hard HEAD~1
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mehrere Schritte zurück
|
||||||
|
|
||||||
|
```
|
||||||
|
git reset --hard <commit-id>
|
||||||
|
```
|
||||||
|
|
||||||
|
! nicht vergessen, anschliessend für remote anpassen:
|
||||||
|
|
||||||
|
```
|
||||||
|
git push -f
|
||||||
|
```
|
||||||
|
|
||||||
|
## Overwrite local history with remote
|
||||||
|
|
||||||
|
```
|
||||||
|
git fetch --all
|
||||||
|
git reset --hard <remote>/<branch-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Eigenen Branch mit dem Master-Branch aktualisieren
|
||||||
|
|
||||||
|
```
|
||||||
|
git checkout master
|
||||||
|
git pull
|
||||||
|
git checkout xyz
|
||||||
|
git rebase -i master
|
||||||
|
```
|
||||||
|
|
||||||
|
... hier die Konflikte lösen ...
|
||||||
|
|
||||||
|
```
|
||||||
|
git add .
|
||||||
|
git rebase --continue
|
||||||
|
git push --force-with-lease
|
||||||
|
```
|
||||||
|
|
||||||
|
## Neuer Branch aus falschem Branch
|
||||||
|
|
||||||
|
### Ausgangslage
|
||||||
|
|
||||||
|
Neuer Branch (b) wurde fälschlicherweise aus einem anderen Branch (a) (anstatt dem Master) erstellt. Die Files aus (a) sind nun doppelt vorhanden, nämlich auch in (b). Bei einem Pull-Request für (b) sind dann die files auch von (a) drin.
|
||||||
|
|
||||||
|
### Problemlösung
|
||||||
|
|
||||||
|
```
|
||||||
|
git checkout master
|
||||||
|
git pull
|
||||||
|
git checkout (b)
|
||||||
|
git pull
|
||||||
|
git rebase -i master
|
||||||
|
```
|
||||||
|
|
||||||
|
bei den commits aus (b), also die, die nicht in den neuen branch gehören, ein d vorne dran (anstatt bestehendem pick) und speichern
|
||||||
|
|
||||||
|
```
|
||||||
|
git log (zum prüfen ob ok)
|
||||||
|
git push --force-with-lease
|
||||||
|
|
||||||
|
```
|
||||||
Loading…
Reference in New Issue
Block a user