
Use git checkout -b to create a branch and switch right into itĬreate a new branch based on a remote branch git branch -track / t checkout a new branch based on remote branch and save their connectionĬreate a new branch based on HEAD git branch Switch to a different branch git checkout Use -a to show local and remote branches at once Stage all changes in tracked files and start a commit git commit -aĬommit all previously staged changes git commit S Try to split the current part into smaller ones Stage a tracked and modified file git add Īdd hand-picked changes in a file to the next commit (≙ partial commit) git add -p ĭ Don’t add this and all remaining parts of the file Stage all (even untracked) files git add -A Show all commits with a certain word in the commit message git log -grep= Show a single commit and its differences git show Left side shows the last commit ID for the content on the right side Show commits and each difference for a specific file git log -p Įxamination: Show who changed what and when in a file git blame Show all commits of current branch and names of each changed file git whatchanged Show all commits of current branch git log Show branches in which one commit exists git branch -contains The reference may be a branch or a tag, note the two dots at the end Show all commits of current branch which are not merged into another branch git log. »+« line does exist in »bar« but not in »foo«, »-« reverseĭifference to another branch and show names of changed files only git diff -name-status Note: This ignores new files = files which were not added to the repository yet and therefore arent »tracked«ĭifference between HEAD and staged files git diff -cachedĭifference between HEAD and all files (staged and not staged) git diff HEADĭifference between branches, two commits, etc git diff Hint: Set a short alias for often used commands, like git st for git status → see ✼onfiguration«ĭifference between HEAD and files not yet staged git diff Show working status - show current branch name and changed or new files git status git subdirectory only) in order to accept a push

The remote repository has to be »bare« (does not contain a working filetree, but a special. Special: Create an empty repository on a remote serverĬonnect with the remote server first mkdir. Send existing local repository to remote git remote add origin & git push If a folder name is given, a subfolder is created, otherwise the current folder is used » HTTPS would be » «, another local repo »/home/user/repo.git«Ĭreates a subfolder with the repo, if the folder name is not given, then the repo name is used (»foo.git« = »./foo« subfolder) remote = bookmark for a repository origin (a repository may have several remotes)Ĭlone an existing repository git clone ĭefault protocoll is SSH, eg.HEAD ≙ reference to the top commit in the current branch.stage ≙ files earmarked for the next commit.commit ≙ object with annotated changes in relation other commits.
