Git: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
|||
| (4 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
=Git= | =Git= | ||
[[Git Aufräumen]] | * [[GIT Anleitung]] | ||
* [[Git Aufräumen]] | |||
* [[.gitconfig]] | |||
=Git alte Einträge= | =Git alte Einträge= | ||
==Neues Projekt hinzufügen== | ==Neues Projekt hinzufügen== | ||
| Zeile 123: | Zeile 126: | ||
Einen zusätzlichen Remotserver für ein Drupal Sandbox Projekt konfigurieren: | Einen zusätzlichen Remotserver für ein Drupal Sandbox Projekt konfigurieren: | ||
git remote add maillog_mailwire | git remote add maillog_mailwire USER@git.drupal.org:sandbox/UESER/1179696.git | ||
=== Push auf anderen Remoteserver === | === Push auf anderen Remoteserver === | ||
Aktuelle Version vom 17. Dezember 2019, 17:30 Uhr
Git
Git alte Einträge
Neues Projekt hinzufügen
DB Aktualisieren
git clone gitosis@isaak:sbav.git
in Datei gitosis.conf
[group ballon-zeberli] members = @edv writable = ballon-zeberli [repo ballon-zeberli] description = ballon-zeberli D7 owner = @edv
Beim Projekt Root Ordner anwählen und mit Rechter Maustaste...
Git Projektarchiv hier stellen
im Subordner .git die datei config
[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true hideDotFiles = dotGitOnly [remote "origin"] url = gitosis@paulus:Projektname.git fetch = +refs/heads/*:refs/remotes/origin/* puttykeyfile = C:\\Users\\Simon\\.ssh\\id_rsa.ppk [branch "master"] remote = origin merge = refs/heads/master
Git Projekt Master eintragen.
Client einstellungen
in datei .gitconfig
[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true hideDotFiles = dotGitOnly [remote "origin"] fetch = +refs/heads/*:refs/remotes/origin/* puttykeyfile = C:\\Users\\Simon\\.ssh\\id_rsa.ppk [branch "master"] remote = origin merge = refs/heads/master
Installation
Häufige Kommandos
Branch erzeugen
git branch branch_name
Zu einem (neuen) Branch wechseln
git checkout <branch_name>
Change to a new branch and create it at the same time
git checkout -b <branch_name>
Diff grafisch darstellen
git difftool -y
Das Diff zwischen zwei Commits:
git difftool -y 3c7a67 39d7a7
A Diff between two branches:
git difftool live dev
A Diff between two version of a file (can be commits or branches):
git difftool mybranch master -- myfile.css
All of the above git difftool commands can also be run on the command line, using diff instead of difftool like this:
git diff live dev -- FileToDiff.txt
Projekt clonen
git clone simon@juda:sbav.git
Letztes Commit löschen
git reset --soft HEAD~1
HEAD~1 is a shorthand for the commit before head. Alternatively you can refer to the SHA-1 of the hash you want to reset to. Note that when using --hard any changes to tracked files in the working tree since the commit before head are lost.
If you don't want to wipe out the work you have done, you can use --soft option that will delete the commit but it will leave all your changed files "Changes to be committed", as git status would put it.
Now if you already pushed and someone pulled which is usually my case, you can't use git reset. You can however do a git revert,
git revert HEAD
This will create a new commit that reverses everything introduced by the accidental commit.
Von Remote Server zurückspielen
git add -A . git pull -v --progress "origin"
Drupal Patch erzeugen
Mit diesem Vorgehen, wird der Commiter in Drupal erhalten, auch wenn man nur einen Patch einreicht und der Maintainer in committed.
git format-patch f5d6d8..b539dd
Im Issue immer folgendes schreiben:
The Patch is done via "git format-patch"
If the patch is applyed, can you please use:
git am --signoff --ignore-whitespace < integrate_with_mailwire-1125778-12.patch
this should keep the commiter for my account :-).
Remoteserver verwalten
Einführung siehe http://progit.org/book/ch2-5.html.
Ausführliche Liste aller Remoteserver anzeigen:
git remote -v
Einen zusätzlichen Remotserver für ein Drupal Sandbox Projekt konfigurieren:
git remote add maillog_mailwire USER@git.drupal.org:sandbox/UESER/1179696.git
Push auf anderen Remoteserver
git push maillog_mailwire 7.x-1.x
Achtun: Es muss immer der aktuelle Branch angegeben werden. Hier also 7.x-1.x und nicht etwa master wie in den Git Doks von Drupal beschrieben.
Grundsätzlich sind nachfolgende Informationen auch via http://www.nslu2-linux.org/wiki/HowTo/HostingGit zu finden.
Email und Autor setzen für ein Repository
git config user.email "simon.zeberli@zeberliedv.ch" git config user.name "Simon"
git-credential-store - Helper to store credentials on disk
git-credential-store documentation
In a situation where multiple people are working on a git file directory it is best to not use the Bonobo Personal URL but to use the Git Repository Pfad as the remote address (add a remote with: git remote add <repository_url>).This is so that each person's commits are credited to his account. This however means that each time you push to the Bonobo repository you will be asked for your username and password.
Git provides a way that you can store you username and password to disk protected by only the filesystem permissions.
Before doing a git push where you would need to enter your username and password run:
git config credential.helper store
You will be asked for your username and password as other times but git will store your login information in less ~/.git-credentials (~ is a shell abbreviation for your home directory. ie. /home/username/). This login information will be used in the future for authentication with that Git server.
To check what login information have been stored run:
less ~/.git-credentials
To check the file permissions on your personal credential file run:
ll ~/.git-credentials
I found that on dev01 the group was set to www-data. For added security you can change the group to your user name with:
chgrp <your_username> ~/.git-credentials
Installation auf PC
Unter http://git-scm.com/download mysysGit herunterladen und installieren. Bei Bedarf git auch unter cygwin installieren.
TortoiseGit installieren (http://code.google.com/p/tortoisegit). Wenn TotalCommander verwendet wird, muss auf 64-Bit Systemen die 32-Bit und die 64-Bit Version installiert werden, sonst werden keine Icons angezeigt.
Beim Installieren folgende Option auswählen:
Folgende SSH Einstellungen:
.gitconfig Anpassen
.gitconfig Datei im Verzeichnis
C:\Users\username\
.gitconfig
[user]
name = Simon Zeberli
email = simon.zeberli@zeberliedv.ch
[core]
autocrlf = false
safecrlf = false
Wenn die icons fehlen:
http://blogs.sitepoint.com/missing-tortoisesvn-file-status-overlay-icons/
1 - Open regedit;
2 - Navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers;
3 - Rename all entries that start with "Tortoise" so they start with "01_Tortoise";
4 - Kill explorer.exe/tgitcache, restart explorer.
Icons aus dem Cache Löschen (Icon Cahce - Rebuild)
If one or more of your
icons are not displaying correctly, or that your icon cache is
corrupted, then you might consider rebuilding the icon cache to reset
and reload the icon images into the icon cache in Vista, Windows 7, and Windows 8.
The icon cache is located at the hidden system folder location below:
C:\Users\%username%\AppData\Local\IconCache.db
SSH installieren
- SSH private Key von cygwin nach
c:\Users\username\.sshkopieren.
Ganzes production Repository auf der Kommandozeile auschecken:
git clone gitosis@juda:zeberliedv.git
Alle repositories unter cygwin auflisten
Folgenden Code ans Ende von .bashrc einfühgen:
function repos
{
gitosisDir="/cygdrive/c/Users/Ernst/Source/gitosis-admin"
awk 'BEGIN { OFS = "[] "; ORS = "\n" }
/repo/ {print $2}' "$gitosisDir/gitosis.conf" | sed 's/[][]//g'
}
Danach wird mit dem Kommando repos eine Liste aller Repositories ausgegeben.
Fehlermeldung Tortoise Git commit/add
fatal: LF would be replaced by CRLF in sites/all/modules/contrib/phone/countries.txt
Problem. Unix Datein mit nur LF wurde unter Windows erstellt/ausgepackt. Lösung: Betreffende Datei(en) unter cygwin mit unix2dos konvertieren. Danach kann normal eingecheckt werden.
Installation auf Synology
Als root folgendes ausführen:
ipkg update ipkg install gitosis
Die SSH Clients müssen ihren public Key hinterlegen. Zuerst auf die Synology kopieren, z.B. via einen Share dann
sudo -H -u gitosis /opt/bin/gitosis-init < /volume1/public/id_rsa.pub
Konfigurieren von gitosis
Danach ist gitosis bereit und kann vom Client aus administriert werden. Das geschiet über das Verändern von Konfigurationsdateien. Wenn diese eingecheckt werden, wir die Konfiguration vorgenommen.
Clonen der Konifguration (auschecken für SVN Benutzer):
git clone gitosis@paulus:gitosis-admin.git
Änderungen werden aktiviert, in dem sie zuerst lokal eingecheckt wird und dann auf den Server gepuscht wird. Im gitosis-admin Verzeichnis folgende Kommandos ausführen.
git commit git push
Neue Benutzer anlegen
- Unter
gitosis-admin\keydirden public SSH Key ablegen. Filename muss dem Musterusername.pubentsprechen - Den Benutzer unter
membersin der Dateigitosis.confin den entsprechenden Gruppen auflisten.
Neues Repository anlegen
In der Datei gitosis.conf folgendes erfassen:
[group heilsarmee] members = @production writable = heilsarmee
[repo heilsarmee] description = heilsarmee owner = ernst
Jetzt gitosis.conf commiten und pushen.
Danach auf dem PC ein beliebiges Verzeichnis heilsarmee erstellen und dort folgende Kommandos eingeben:
git init git remote add origin gitosis@isaak:heilsarmee.git
Jetzt können lokal irgendwelche Dateien erzeugt/geändert werden.
Dateien hinzufügen:
git add .
Einchecken aller Änderungen:
git commit -a -m "initiales Commit"
Jetzt können alle Änderungen auf den Server verschoben werden:
git push origin master
Repository löschen
- Zuerst das Repository in der
gitosis.confDatei entfernen, committen und pushen. - Dann auf den Server einlogen und das Repositoryverzeichnis unter
/opt/share/gitosis/repositoriesentfernen.
Drupal Cache-Verzeichnisse von git ausschliessen
Die Datei .gitignore im Rootverzeichnis des Projektes anlegen.
Inhalt:
sites/default/files/css sites/default/files/js sites/default/files/languages sites/default/files/imagecache sites/default/files/backup_migrate sites/default/files/tmp
gitosis Pfad in der Synology
Alle Daten sind auf isaak unter
/opt/share/gitosis
abgelegt.