projektmanagement.html engineering.html


GIT necessary commands for me ...



tools for git

https://www.gitextensions.com https://www.gitkraken.com

master origin head etc

master

origin

HEAD

HEAD^

HEAD~3

default development branch

default upstream repository

current branch

parent of HEAD

great-grandparent of HEAD



create

browse

change

revert

update

branch

commit

publish

init
clone

status
log
show
diff
branch

c++/c# coding or equal

reset
checkout
revert

pull
fetch
merge
am

checkout
branch

commit

push
format-patch



Clone from an existing repository in a directory

Clone from an existing repository git

Clone from an existing repository http

Clone from an existing repository ssh

Create from an existing project directory

git clone ~/repo ~/new/repo

git clone git://xyz.org/ultra_project.git

git clone http://www.xyz.org/ultra_project.html

git clone ssh://repo@xyz.org/ultra_project.git

cd ultra_project
git init
git add .



Now following some more or less important commands for the git universe ...

git log

git log

All log entries of the history log for all authors.

git log --author=xy

All log entries of the history log for the author xy.

git log --[file]

All log entries of the history log for that specific file.

git log origin

All log entries for origin.

git log -p $file $directory

History for $file with diffs in $directory.


git blame

git blame $file

List each line of the $file with information about the author, commit and last modification date.

git blame $file -L42,666

Like before, but only from line 42 to 666.

git blame $file -L42,666 -e

Like before, but here instead of the author you will get the email address.


git whatchanged, status and reflog<

git whatchanged

A nice briefing what difference each commit introduces.

git whatchanged --author=$author

Like before, but only for that author.

git status

Show what files are modified in the working directory.

git reflog

Show reflog information.


git show

git show

Show information about commits ordered backwards.

git show $id

Show information about commit with that $id.

git show $id:$file

Show information about commit with that $id only for that $file.

git show --author=$author

Show information about commits by that specific author.


git push

git push

1st ci, 2nd pull and 3rd push it to the global repository.

git push --dry-run

helpful parameter - only a virtual push, so one can first test.


git branch

git branch

Show branches and current branch is marked with an asterisk.

git branch -a

Show all branches, includes the remote repository.

git branch -r

Show all remote branches.

git branch -m old new

Rename old in new.


git delete branch

git branch -d $branch

Delete $branch from the local repository.

git push origin :$branch

Push $branch to the global repository origin and delete it local!

git push origin --delete $branch

Push $branch to the global repository origin and delete it local!


git commit

git commit

Show branches and current branch is marked with an asterisk.

git ci -a -m "XX"

Commit all tracked modified files in the local repository under log entry "XX".


git fetch and pull

git pull

Pull from the remote repository and update the current branch. Is not possible with uncommitted files.

git fetch

Fetch from the remote repository without updating the cuurent branch. Is possible with an uncommitted state.


git checkout

git checkout $branch

Checkout and switch to $branch.

git checkout $branch $file"

But here only the $file is checked out from $branch.

git checkout -- '*.c'

If you want to check out all C source files out of the index, you do it this way (use carefully).

git checkout -b $branch_new $branch_old"

Create $branch_new (based on $branch_old) and switch to it.


git diff

git diff

Show changes in the working tree that are not yet staged for the next commit.

git diff $branch

Instead of using the tip of the current branch, compare with the tip of $branch.

git diff HEAD -- ./$file

Compare with the tip of the current branch, but limit the comparison to the $file.

git diff HEAD^ HEAD

Compare the version before the last commit and the last commit.

git diff HEAD~1 HEAD --name-status

Get a list like for svn with file and state.

git diff --find-copies-harder -B -C

Spend extra cycles to find renames, copies and complete rewrites (very expensive).

git diff -R

Output diff in reverse.

git diff HEAD~2 HEAD --stat

Shows a statistics.

git diff HEAD~2 HEAD --numstat

Shows a statistics.

git diff --stat $branch $path

Shows a statistics for the $path of that $branch.

git diff 182e2a690d8eb0453f33e5bbc945a8e243d9c057 a4a1c8121520e29466dbd8d656fa34bb6e88959f --stat

Shows differences between those two commits - here with statistics.


git revert and reset

git revert HEAD

Revert the last commit-

git revert $id

Revert a specific commit.

git reset --hard

Return to the last committed state.

git reset --hard HEAD~1

Return to the committed state for HEAD~1.


helpful git commands

git branch -r --contains $id

in which branches is commit with $id included

git diff-tree --no-commit-id --name-only -r $id

list all by commit $id changed files

change staged file to unstaged

git ls-files --stage                                    
100644 01234567890123456789012345678901234567 0    file1
100644 xy234567890123456789012345678901234567 0    file2
100644 ab234567890123456789012345678901234567 0    file3

git rm --cached file3                                   
git ls-files --stage                                    
100644 01234567890123456789012345678901234567 0    file1
100644 xy234567890123456789012345678901234567 0    file2

TODO

merge

diff for merge-conflicts

cherry-pick

gitk

git extensions

kdiff

...