Merged PR 305: new: Git command Know-How hinzugefügt.
Hoi @<Christian Fravi> , nur zur Info, ich füge nach und nach hier Know-How Sachen ein, in der Hoffnung die dienen dir dann. Wenn du bei egal welchem Thema anstehst, lass es mich wissen. Chancen sind gegeben, dass ich da irgendwo Schmierzettel oder Notizen habe, welche ich sinnvoll aufbereiten und teilen kann. Den PR musst du nicht reviewen oder freigeben. Dient nur als Gefäss, damit du diese Nachricht und die damit verbundenen Änderungen bekommst. Danke & Gruss JJ
This commit is contained in:
commit
f0e10bd520
1 changed files with 124 additions and 0 deletions
124
know-how/git-commands
Normal file
124
know-how/git-commands
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
# Git Commands
|
||||
|
||||
## Random ideas
|
||||
|
||||
[Kart: DVC for geospatial and tabular data. Git for GIS](https://kartproject.org/), [Discussion](https://news.ycombinator.com/item?id=38073512#git), [Go to Post from 2023-10-30T20:40:06](https://social.lansky.name/@hn50/111325898767760054)
|
||||
|
||||
[Use KeePassXC to sign your git commits](https://code.mendhak.com/keepassxc-sign-git-commit-with-ssh/)
|
||||
|
||||
## Git commands and examples
|
||||
|
||||
Create a new branch locally within a already cloned repository:
|
||||
|
||||
```bash
|
||||
git branch -b <branch-name>
|
||||
```
|
||||
|
||||
Delete local branch
|
||||
|
||||
```bash
|
||||
git branch -d <branch-name>
|
||||
```
|
||||
|
||||
Rebase auf main branch:
|
||||
|
||||
```bash
|
||||
git fetch
|
||||
git rebase origin/main
|
||||
git push origin HEAD -f
|
||||
```
|
||||
|
||||
Abort rebase:
|
||||
|
||||
```bash
|
||||
git rebase --abort
|
||||
```
|
||||
|
||||
Stash changes
|
||||
|
||||
```bash
|
||||
git stash
|
||||
git stash pop
|
||||
```
|
||||
|
||||
Revwert a commit:
|
||||
|
||||
```bash
|
||||
# Sollte funktionieren, wenn nur 1 Commit geamcht wurde
|
||||
git reset --soft HEAD~1
|
||||
|
||||
# Eher Brechstange:
|
||||
git revert cb7cf15b54ff09495201244b070d18d96d4703ce
|
||||
git reset --hard HEAD~2
|
||||
```
|
||||
|
||||
Show changes beween two tags:
|
||||
|
||||
```bash
|
||||
# tag from previouse version
|
||||
git tag -a v0.1.0 -m "Release version 0.1.0"
|
||||
|
||||
# add changes
|
||||
git commit -am "add hint for change log"
|
||||
# and more
|
||||
|
||||
# add final tag vor version
|
||||
git tag -a v0.2.0 -m "Release version 0.2.0"
|
||||
|
||||
# show diff between tags
|
||||
git log v0.1.0..v0.2.0 --no-merges --format="%h - %s" --date=short
|
||||
```
|
||||
|
||||
Git diff log between commits
|
||||
|
||||
```bash
|
||||
git log 79e28d9cef4cc777afc9e5b2569a5d34d9331867..6888fd61ae9d5744effcf27620a645e1750cbafc --no-merges --format="%h - %s (%an, %ad)" --date=short
|
||||
```
|
||||
|
||||
Debug SSH connection via git
|
||||
|
||||
```bash
|
||||
GIT_SSH_COMMAND="ssh -v"
|
||||
git pull
|
||||
unset GIT_SSH_COMMAND
|
||||
```
|
||||
|
||||
Add executable flag on windows
|
||||
|
||||
```bash
|
||||
git update-index --chmod=+x git_mirror.sh
|
||||
```
|
||||
|
||||
check the remote branch of a cloned repository and change it
|
||||
|
||||
```bash
|
||||
|
||||
git remote -v
|
||||
|
||||
git remote set-url origin xwr@vs-ssh.visualstudio.com:v3/xwr/jambor.pro/app-docker-compose
|
||||
|
||||
git remote -v
|
||||
|
||||
for branch in $(git branch -r | grep -v '\->'); do
|
||||
git checkout ${branch#origin/}
|
||||
git push -u origin HEAD
|
||||
git push --tags origin
|
||||
done
|
||||
```
|
||||
|
||||
Renaming branches
|
||||
|
||||
```bash
|
||||
|
||||
# delete remote branch
|
||||
git push origin --delete wikiMaster
|
||||
|
||||
# delete local branch
|
||||
git branch -d wikiMaster
|
||||
|
||||
# move branch
|
||||
git branch -m main wikiMaster
|
||||
|
||||
# push
|
||||
git push origin HEAD
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue