GIT Cheatsheet

windows filename too long

Wenn z.B.: error: open("Resources/Public/JS/MySuperScript.js"): Filename too long dann die Git Bash ALS ADMIN öffenn und git config --system core.longpaths true setzen.
Quelle

Änderungen zurücksetzen

Discard all local changes, but save them for possible re-use later
git stash
Discarding local changes (permanently) to a file
git checkout -- <file>
Discard all local changes to all files permanently
git reset --hard

tags

git tag Tags anzeigen
git tag v1.4 einfachen Tag anlegen
git tag -a v1.4 -m 'my version 1.4' Kommentierten Tag anlegen
git tag -a v1.2 -m 'version 1.2' 9fceb02 Nachträglich taggen mit commit Prüfsumme
git push origin v1.5 Tag pushen
git push origin --tags Viele Tags pushen
Quelle

checkout remote branch in lokales repo?

git checkout -t <remote>/<branch>
git checkout -b test <remote>/<branch> (länger)
git checkout --track -b <branch> <remote>/<branch> (noch länger)
Quelle

Dateirechte bei git diff ignorieren?

git -c core.fileMode=false diff
Nicht pauschal deaktivieren. Besser die Dateirechte mit find . -type d -exec chmod a+rwx {} \; # Make folders traversable and read/write und find . -type f -exec chmod a+rw {} \; # Make files read/write setzen! Sicherheitsrisiko!
Quelle

which remote branch a local branch is tracking?

git branch -vv
Quelle

Delete a Local GIT branch

git branch -d <branch_name>
Quelle

Delete a remote GIT branch

git push <remote_name> --delete <branch_name>
git push <remote_name> :<branch_name>
Quelle

copy branch to a new local branch

git checkout old_branch
git branch new_branch
This will give you a new branch "new_branch" with the same state as "old_branch".

combined: git checkout -b new_branch old_branch
Quelle

branching / merging in a nutshell

create branch
git checkout -b iss53
Switched to a new branch ‚iss53‘

do something in branch & commit
vim index.html
git commit -a -m ‚added a new footer [issue 53]‘

go back to master
git checkout master
Switched to branch ‚master‘

merge other branch in actual one
git merge iss53

branch löschen
git branch -d iss53

Quelle + Tipps bei Fehlern

git branch options

git branch
-d | –delete Delete a branch. The branch must be fully merged in its upstream branch, or in HEAD if no upstream was set with --track or --set-upstream-to.

-m | –move Move/rename a branch and the corresponding reflog.

-c | –copy Copy a branch and the corresponding reflog.

-r | –remotes List or delete (if used with -d) the remote-tracking branches.

-a | –all List both remote-tracking branches and local branches.

-v | -vv | –verbose When in list mode, show sha1 and commit subject line for each head, along with relationship to upstream branch (if any). If given twice, print the name of the upstream branch, as well (see also git remote show <remote>).

-t | –track When creating a new branch, set up branch.<name>.remote and branch.<name>.merge configuration entries to mark the start-point branch as "upstream" from the new branch. This configuration will tell git to show the relationship between the two branches in git status and git branch -v. Furthermore, it directs git pull without arguments to pull from the upstream when the new branch is checked out.

This behavior is the default when the start point is a remote-tracking branch. Set the branch.autoSetupMerge configuration variable to false if you want git checkout and git branch to always behave as if --no-track were given. Set it to always if you want this behavior when the start-point is either a local or remote-tracking branch.

–set-upstream As this option had confusing syntax, it is no longer supported. Please use --track or --set-upstream-to instead.

-u <upstream> | –set-upstream-to=<upstream> Set up <branchname>’s tracking information so <upstream> is considered <branchname>’s upstream branch. If no <branchname> is specified, then it defaults to the current branch.

Quelle

Schreibe einen Kommentar

Datenschutzhinweise: Die E-Mailadresse wird an den Dienst Gravatar (der Firma Auttomatic) weiter geleitet, um zu prüfen, ob die Kommentatoren dort ein Profilbild hinterlegt haben. Sie wir jedoch NICHT veröffentlicht. Zu Details hierzu sowie generell zur Verarbeitung Ihrer Daten und Widerrufsmöglichkeiten, verweisen wir Sie auf unsere Datenschutzerklärung. Ebenfalls finden Sie dort Hinweise zu Kommentar-/Postabonnements und Hinweise zum Widerrufsrecht. Sie können für Kommentare auch gerne Pseudonyme verwenden. Erforderliche Felder sind mit * markiert.

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert


Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.