Menade du?

    git

    Logotyp för Git Logotyp för Git

    Filändelser

    • .git

    Fil

    Fil

    README.md

    Specialtecken

    • ~
    • ^
    • -
    Logotyp för FA - Font Awesome

    Namn och kodpunkt för ikoner från Font Awesome 4.7.0 (den sista versionen som var helt gratis)

    • fa-git
    • fa-git-square
    • fa-code-fork

    • fa-gitlab
    • fa-bitbucket
    • fa-bitbucket-square
    • fa-github
    • fa-github-alt
    • fa-github-square

    Förkortningar som används vid rebase

    • p - pick
    • r - reword
    • e - edit
    • s - squash
    • f - fixup
    • x - exec
    • b - break
    • d - drop
    • l - label
    • t - reset
    • m - merge

    Förkortningar

    • CR - Code Review

    • SCM - Source Code Management
    • LFS - Git Large File Storage
    • PR - Pull Requests

    • CO - checkout
    • CI - commit
    • ST - status
    • BR - branch

    • mv -
    • rm -
    Git flow Informativa commits

    Hooks

    .git/hooks

    Citat

    Already up-to-date
    ¯\_(ツ)_/¯
    Logotyp för Gerrit Maskot och logotyp för GitLab Maskot och logotyp för GitLab Logotyp för GitHub Logotyp för Bitbucket Logotyp för Bitbucket Logotyp för Pantheon Logotyp för Gitlens Logotyp för Gitlens

    Tjänster

    Ikon med logotyp för Coda Logotyp för Smartgit Logotyp för Git tower Logotyp för SourceTree Logotyp för SmartGit Logotyp för GitKraken Logotyp för TortoiseGit Logotyp för TortoiseGit Logotyp för Gitfork

    Program

    Logotyp för Subversion

    Liknande

    • CVS
    • Mercurial
    • SVN (Subversion)

    Exempel på ett repo som man kan klona

    git clone https://github.com/git/git

    Publishing a Local Branch

    git push -u origin name-of-the-branch

    Gerrit

    git push origin HEAD:refs/for/development

    Fetch

    git fetch

    Blame

    git blame <file>

    Reset

    git reset --hard origin/development git reset --hard SHAsum of your commit

    list remote branches

    git branch -a

    Shorthand

    git checkout -b iss53

    This is shorthand for

    git branch iss53 git checkout iss53

    Hjälp

    Visa all hjälp usage: git [-v | --version] [-h | --help] [-C ] [-c =] [--exec-path[=]] [--html-path] [--man-path] [--info-path] [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare] [--git-dir=] [--work-tree=] [--namespace=] [--super-prefix=] [--config-env==] [] These are common Git commands used in various situations: start a working area (see also: git help tutorial) clone Clone a repository into a new directory init Create an empty Git repository or reinitialize an existing one work on the current change (see also: git help everyday) add Add file contents to the index mv Move or rename a file, a directory, or a symlink restore Restore working tree files rm Remove files from the working tree and from the index examine the history and state (see also: git help revisions) bisect Use binary search to find the commit that introduced a bug diff Show changes between commits, commit and working tree, etc grep Print lines matching a pattern log Show commit logs show Show various types of objects status Show the working tree status grow, mark and tweak your common history branch List, create, or delete branches commit Record changes to the repository merge Join two or more development histories together rebase Reapply commits on top of another base tip reset Reset current HEAD to the specified state switch Switch branches tag Create, list, delete or verify a tag object signed with GPG collaborate (see also: git help workflows) fetch Download objects and refs from another repository pull Fetch from and integrate with another repository or a local branch push Update remote refs along with associated objects 'git help -a' and 'git help -g' list available subcommands and some concept guides. See 'git help ' or 'git help ' to read about a specific subcommand or concept. See 'git help git' for an overview of the system.

    Alias alias | grep git

    Visa alla alias egrep='grep -E --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}' fgrep='grep -F --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}' g=git ga='git add' gaa='git add --all' gam='git am' gama='git am --abort' gamc='git am --continue' gams='git am --skip' gamscp='git am --show-current-patch' gap='git apply' gapa='git add --patch' gapt='git apply --3way' gau='git add --update' gav='git add --verbose' gb='git branch' gbD='git branch -D' gba='git branch -a' gbd='git branch -d' gbda='git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch -d 2>/dev/null' gbl='git blame -b -w' gbnm='git branch --no-merged' gbr='git branch --remote' gbs='git bisect' gbsb='git bisect bad' gbsg='git bisect good' gbsr='git bisect reset' gbss='git bisect start' gc='git commit -v' 'gc!'='git commit -v --amend' gca='git commit -v -a' 'gca!'='git commit -v -a --amend' gcam='git commit -a -m' 'gcan!'='git commit -v -a --no-edit --amend' 'gcans!'='git commit -v -a -s --no-edit --amend' gcas='git commit -a -s' gcasm='git commit -a -s -m' gcb='git checkout -b' gcd='git checkout $(git_develop_branch)' gcf='git config --list' gcl='git clone --recurse-submodules' gclean='git clean -id' gcm='git checkout $(git_main_branch)' gcmsg='git commit -m' 'gcn!'='git commit -v --no-edit --amend' gco='git checkout' gcor='git checkout --recurse-submodules' gcount='git shortlog -sn' gcp='git cherry-pick' gcpa='git cherry-pick --abort' gcpc='git cherry-pick --continue' gcs='git commit -S' gcsm='git commit -s -m' gcss='git commit -S -s' gcssm='git commit -S -s -m' gd='git diff' gdca='git diff --cached' gdct='git describe --tags $(git rev-list --tags --max-count=1)' gdcw='git diff --cached --word-diff' gds='git diff --staged' gdt='git diff-tree --no-commit-id --name-only -r' gdup='git diff @{upstream}' gdw='git diff --word-diff' gf='git fetch' gfa='git fetch --all --prune --jobs=10' gfg='git ls-files | grep' gfo='git fetch origin' gg='git gui citool' gga='git gui citool --amend' ggpull='git pull origin "$(git_current_branch)"' ggpush='git push origin "$(git_current_branch)"' ggsup='git branch --set-upstream-to=origin/$(git_current_branch)' ghh='git help' gignore='git update-index --assume-unchanged' gignored='git ls-files -v | grep "^[[:lower:]]"' git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk' gk='\gitk --all --branches &!' gke='\gitk --all $(git log -g --pretty=%h) &!' gl='git pull' glg='git log --stat' glgg='git log --graph' glgga='git log --graph --decorate --all' glgm='git log --graph --max-count=10' glgp='git log --stat -p' glo='git log --oneline --decorate' glod='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'\' glods='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset'\'' --date=short' glog='git log --oneline --decorate --graph' gloga='git log --oneline --decorate --graph --all' glol='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'\' glola='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'\'' --all' glols='git log --graph --pretty='\''%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset'\'' --stat' glp=_git_log_prettily gluc='git pull upstream $(git_current_branch)' glum='git pull upstream $(git_main_branch)' gm='git merge' gma='git merge --abort' gmom='git merge origin/$(git_main_branch)' gmtl='git mergetool --no-prompt' gmtlvim='git mergetool --no-prompt --tool=vimdiff' gmum='git merge upstream/$(git_main_branch)' gp='git push' gpd='git push --dry-run' gpf='git push --force-with-lease' 'gpf!'='git push --force' gpoat='git push origin --all && git push origin --tags' gpr='git pull --rebase' gpristine='git reset --hard && git clean -dffx' gpsup='git push --set-upstream origin $(git_current_branch)' gpu='git push upstream' gpv='git push -v' gr='git remote' gra='git remote add' grb='git rebase' grba='git rebase --abort' grbc='git rebase --continue' grbd='git rebase $(git_develop_branch)' grbi='git rebase -i' grbm='git rebase $(git_main_branch)' grbo='git rebase --onto' grbom='git rebase origin/$(git_main_branch)' grbs='git rebase --skip' grep='grep --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn,.idea,.tox}' grev='git revert' grh='git reset' grhh='git reset --hard' grm='git rm' grmc='git rm --cached' grmv='git remote rename' groh='git reset origin/$(git_current_branch) --hard' grrm='git remote remove' grs='git restore' grset='git remote set-url' grss='git restore --source' grst='git restore --staged' grt='cd "$(git rev-parse --show-toplevel || echo .)"' gru='git reset --' grup='git remote update' grv='git remote -v' gsb='git status -sb' gsd='git svn dcommit' gsh='git show' gsi='git submodule init' gsps='git show --pretty=short --show-signature' gsr='git svn rebase' gss='git status -s' gst='git status' gsta='git stash push' gstaa='git stash apply' gstall='git stash --all' gstc='git stash clear' gstd='git stash drop' gstl='git stash list' gstp='git stash pop' gsts='git stash show --text' gsu='git submodule update' gsw='git switch' gswc='git switch -c' gswd='git switch $(git_develop_branch)' gswm='git switch $(git_main_branch)' gtl='gtl(){ git tag --sort=-v:refname -n -l "${1}*" }; noglob gtl' gts='git tag -s' gtv='git tag | sort -V' gunignore='git update-index --no-assume-unchanged' gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' gup='git pull --rebase' gupa='git pull --rebase --autostash' gupav='git pull --rebase --autostash -v' gupom='git pull --rebase origin $(git_main_branch)' gupomi='git pull --rebase=interactive origin $(git_main_branch)' gupv='git pull --rebase -v' gwch='git whatchanged -p --abbrev-commit --pretty=medium' gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign -m "--wip-- [skip ci]"'

    Git alias

    .gitconfig [alias] co = checkout ci = commit st = status br = branch

    Skapa branchserver

    git push --set-upstream origin marked merge branch master

    Show remotes

    git remote -v git remote set-url origin git@gitlab.com:company/project.git git remote set-url origin https://github.com/USERNAME/REPOSITORY.git

    Switch to a new branch

    git checkout -b new_branch

    Delete a branch

    git branch -d the_local_branch

    Difference

    git diff HEAD

    Fast forward

    How can i git stash a specific file?

    git stash git stash -p git pull (--rebase) git stash pop

    Branch

    git checkout -b iss53 git branch iss53 git checkout iss53

    Version av git

    git --version

    Vilken git?

    which git

    Sökväg

    /usr/local/bin/git /usr/bin/git

    Soft reset

    git reset --soft HEAD^

    Hard reset

    git reset --hard HEAD

    Git global setup

    git config --global user.name "Firstname Lastname" git config --global user.email "firstname.lastname@mail.com"

    Radbrytning för Windows i Git med UNIX

    git config --global core.autocrlf "true"

    Varning om radbrytningar

    warning: LF will be replaced by CRLF in index.html. The file will have its original line endings in your working directory

    git push To ssh://localhost:22/folder/repository.git ! [rejected] branch -> branch (non-fast-forward) error: failed to push some refs to 'ssh://localhost:22/folder/repository.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. git commit --amend --reset-author

    Kommando för att överblicka konfiguration

    git config --global --list git config --list

    Fil med konfiguration

    ~/.gitconfig

    Fil med andra filer att ignorera

    .gitignore

    How to show your Git username

    git config user.name

    How to change your Git username

    git config --global user.name "Firstname Lastname"

    How to show your Git email address

    git config user.email

    How to change your Git email address

    git config --global user.email firstname.lastname@domain.com

    Show remote origin

    git remote show origin

    Skapa ett nytt repository

    mkdir project cd project git init touch README.md git add README.md git commit -m "first commit" git remote add origin git@git.domain.com:folder/project.git git push -u origin master

    Push an existing Git repository

    cd existing_git_repo git remote add origin git@git.domain.com:folder/project.git git push -u origin master

    Unignore file

    !/unignore.extension

    Remove a commit

    git rebase -i HEAD~2 git push origin +master

    Change remote origin url

    git remote set-url origin https://github.com/user/project

    Changes in gitignore

    git rm -r --cached . git add . git commit -m ".gitignore is now working"

    Add new remote

    git remote add origin git@github.com:folder/project.git

    Push to another remote

    git push heroku master

    Ångra merge

    git reset --merge

    Cherry pick

    git cherry-pick feff2d158478e012427247cc249a7efa4329d21c

    Empty Git submodule folder when repo cloned

    git clone https://domain.com/user/repo.git --recursive

    git revert -n <HASH>

    git rev-parse HEAD

    Lägg till en tag

    git tag example

    Push av taggar

    git push --tags

    List the stash

    git stash list

    Content of an arbitrary stash

    git stash show -p stash@{1}

    Git log

    git log --pretty=oneline --abbrev-commit git log --pretty=format:"%h%x09%an%x09%ad%x09%s" git log --pretty="%C(Yellow)%h %C(reset)%ad (%C(Green)%cr%C(reset))%x09 %C(Cyan)%an: %C(reset)%s" Linus Torvalds

    Personer

    Kommandon

    • git-checkout
    • git-merge
    • git-commit
    • git-branch
    • git-status
    • git-add
    • git-mergetool
    • git-reset

    • git revert
    • git stash
    • git log
    • git diff
    • git show
    • Clone

    • Push
    • Pull

    • Update
    • Commit (--amend)

    • Repository
    • Checkout

    Alias

    • co = checkout
    • ci = commit
    • st = status
    • br = branch

    • hist = log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short
    • type = cat-file -t
    • dump = cat-file -p

    Git på svenska

    Verb

    Substantiv

    Verb Nuvarande bruk Förslag
    pull pulla rycka
    push pusha knuffa
    fetchtd> fetcha hämta
    branch brancha förgrena
    commit commita förbinda
    rebase rebasa ympa
    merge merga sammanfoga
    squash squasha mosa
    stash stasha gömma
    tag tagga märka
    cherry-pick cherry-picka plocka russin
    amend amenda rätta till
    blame blamea klandra
    Substantiv Nuvarande bruk Förslag
    git git jävel
    repository repo förvaring
    branch branch gren
    commit commit förbindelse
    pull request pull request ryckbegäran
    stash stash gömma
    tag tagg märke

    Lägg till alias för Git på svenska

    git config --global alias.ryck pull git config --global alias.knuffa push git config --global alias.gren branch git config --global alias.forgrena branch git config --global alias.forbinda commit git config --global alias.ympa rebase git config --global alias.sammanfoga merge git config --global alias.gom stash git config --global alias.klandra blame git config --global alias.marke tag git config --global alias.mark tag alias jävel=git

    Lägg till submodul

    git submodule add https://github.com/bjorne/git-pa-svenska.git

    Filer

    ~/.gitconfig

    Interaktiv rebase

    grb --interactive

    git restore --staged

    Ta bort senaste commit

    git reset --hard HEAD~1

    Push

    git push -f origin HEAD Omslagsbild för Divergent

    git pull

    gl --rebase ✗ gl hint: Pulling without specifying how to reconcile divergent branches is hint: discouraged. You can squelch this message by running one of the following hint: commands sometime before your next pull: hint: hint: git config pull.rebase false # merge (the default strategy) hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only hint: hint: You can replace "git config" with "git config --global" to set a default hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation.

    Already up to date.

    error: You have not concluded your merge (MERGE_HEAD exists). hint: Please, commit your changes before merging. fatal: Exiting because of unfinished merge. Körsbär

    Kuriosa

    Operativsystem

    fatal: detected dubious ownership in repository

    UNIX

    git config --global --add safe.directory '*' eller chown -R root .

    Funktioner

    Pull Request VS Merge Request

    Aktiviteter

    • Merge request

    Externa länkar

    A successful Git branching model Grenar på ett träd

    Installera git med DOS

    winget install --id Git.Git -e --source winget