GIT: Unterschied zwischen den Versionen

Aus wiki
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: «= Commands = Delete all remotely deleted files git rm $(git ls-files --deleted)»)
 
 
(9 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
 +
= Basics =
 +
* [[BasicGit|BasicGit]]
 
= Commands =
 
= Commands =
 
Delete all remotely deleted files
 
Delete all remotely deleted files
 
  git rm $(git ls-files --deleted)
 
  git rm $(git ls-files --deleted)
 +
 +
View File 2 Commits before
 +
git show HEAD~2:public/app/styles/main.css
 +
 +
Show conflicted files during merge
 +
git diff --name-only --diff-filter=U
 +
 +
Search File in Log
 +
git log --diff-filter=D --summary | grep '''filename''' | awk '{print $4; exit}' | xargs git log --all --
 +
 +
Nice Git log
 +
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
 +
src: https://coderwall.com/p/euwpig/a-better-git-log
 +
 +
As git alias command:
 +
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
 +
just use git lg
 +
 +
Set new remote url for git repo:
 +
git remote set-url origin git@github.com:ChristofBuechi/RetrofitExample.git
 +
 +
Rebase
 +
rebase a commit-history to a new base. Means if you have a few commits local, which are based on a commit from a different branch,
 +
you can move this stack of commits to another branch or commit. Basically it is a cut and paste of commits on a new base
 +
 +
Merge -no fast forward
 +
Git creates no merge commit if the merge is fast forward. To force git to make a commit:
 +
http://stackoverflow.com/questions/2500296/can-i-make-fast-forwarding-be-off-by-default-in-git
 +
for all branches in the repo (git config --add merge.ff false)
 +
Or git merge -no-ff in every merge
 +
 +
it allows you to revert a merge if accidentally happen
 +
 +
Set new remote tracking branch:
 +
git branch --set-upstream-to origin/branchname branchname

Aktuelle Version vom 4. Oktober 2017, 08:54 Uhr

Basics

Commands

Delete all remotely deleted files

git rm $(git ls-files --deleted)

View File 2 Commits before

git show HEAD~2:public/app/styles/main.css

Show conflicted files during merge

git diff --name-only --diff-filter=U

Search File in Log

git log --diff-filter=D --summary | grep filename | awk '{print $4; exit}' | xargs git log --all --

Nice Git log

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
src: https://coderwall.com/p/euwpig/a-better-git-log

As git alias command:

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
just use git lg

Set new remote url for git repo:

git remote set-url origin git@github.com:ChristofBuechi/RetrofitExample.git

Rebase

rebase a commit-history to a new base. Means if you have a few commits local, which are based on a commit from a different branch, 
you can move this stack of commits to another branch or commit. Basically it is a cut and paste of commits on a new base

Merge -no fast forward

Git creates no merge commit if the merge is fast forward. To force git to make a commit:
http://stackoverflow.com/questions/2500296/can-i-make-fast-forwarding-be-off-by-default-in-git
for all branches in the repo (git config --add merge.ff false)
Or git merge -no-ff in every merge

it allows you to revert a merge if accidentally happen

Set new remote tracking branch:

git branch --set-upstream-to origin/branchname branchname