git ed

Noch ein Quellcode-Verwalte-Programm, aber dezentral, mächtiger und von Linus Torvalds.

Use cases ed

Basic rule: most commands only operate on the current branch!

regular editing ed

clone
git clone REPO    # or
git clone REPO .

start fresh
git init .

new commit
# edit files
git add ...
git commit

add more to last commit
git commit --amend

undo changes
git restore --staged FILES  # unstage if staged
git restore FILES           # restore if unstaged

undo but keep changes
git stash
# ...
git stash pop

branches ed

new
git branch NAME       # or
git checkout -b NAME

list
git branch
git branch --all   # also remote

jump into
git checkout NAME

delete
git branch -d NAME
git branch -D NAME  # even if unmerged

merge
git merge OTHER_SOURCE_BRANCH

remotes ed

...

changing history ed

changing old commits
git rebase LAST_COMMIT_BEFORE_CHANGE -i
# "pick" -> "edit"
# edit files
git add ...
git commit --amend
git rebase --continue

with "edit" we end up just after the commit was ...commited

splitting old commits
git rebase LAST_COMMIT_BEFORE_CHANGES -i
# "pick" -> "edit"
git reset HEAD~      # "open up" previous commit
git add ...
git commit
git add ...
git commit
git rebase --continue

komplex ed

Repository in Unterverzeichnis importieren ed

git subtree add --prefix=SUBFOLER REPO-URL master

Branch remote loeschen ed

git push -d REMOTE BRANCH

lokal loeschen, wenn remote schon geloescht wurde
git pull -p    # --prune

veröffentlichen (http) ed

veröffentlichen (bei jeder Änderung nochmal)

zuerst ein 'nacktes' Repository-Verzeichnis erstellen

git clone --bare NEUES_VERZEICHNIS.git QUELL_REPO
touch NEUES_VERZEICHNIS.git/git-daemon-export-ok

dann auf den Server in ein öffentliches Verzeichnis schicken und dort

git --bare update-server-info
mv hooks/post-update.sample hooks/post-update

importieren (neu)

git clone SERVER/VERZEICHNIS.git

lädt das Repository herunter und erzeugt dazu ein Unterverzeichnis mit dem ursprünglichen Verzeichnisnamen

Categories: Computer, Programmieren