0% found this document useful (0 votes)
140 views1 page

Git Cheat Sheet - Wall Skills1

Git is a version control system that allows users to create, update, and publish changes to code or documents. It provides commands to initialize a repository, add and commit changes locally, pull updates from or push changes to a remote repository, create and switch between branches, revert changes, and view the history of changes. Common workflows involve making changes on a local branch, committing them, pulling updates from the remote, resolving any conflicts, and pushing changes back out.

Uploaded by

jesus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
140 views1 page

Git Cheat Sheet - Wall Skills1

Git is a version control system that allows users to create, update, and publish changes to code or documents. It provides commands to initialize a repository, add and commit changes locally, pull updates from or push changes to a remote repository, create and switch between branches, revert changes, and view the history of changes. Common workflows involve making changes on a local branch, committing them, pulling updates from the remote, resolving any conflicts, and pushing changes back out.

Uploaded by

jesus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Create Update Publish

Git Cheat Sheet From existing data


cd ~/projects/myproject
Fetch latest changes from origin
git fetch
this does not merge them
Commit all local changes
git commit -a
git init
Pull latest changes from origin Prepare a patch for other developpers
git add .
git pull git format-patch origin
From existing repo does a fetch followed by a merge
Push changes to origin
git clone ~/existing/repo ~/new/repo Apply a patch that someone sent you git push [origin] [branch]
git clone [email protected]:dir/project.git git am -3 patch.mbox
default protocol is ssh In case of conflict, resolve the conflict and Make a version or milestone
git am --resolve git tag <version_name>
Remote repository for existing local data
mkdir repo.git && cd repo.git
git init --bare [--shared=group]
see help for info

Workflow

update
branch pull
checkout fetch
branch merge
am
browse
status change
create using your publish
log favorite editor commit
init push
show commit
clone format-patch
diff
branch revert
reset
checkout
revert

Branch Revert Show


Switch to the BRANCH branch Return to the last committed state Files changed in working directory
git checkout <BRANCH> git checkout -f | git reset --hard git status
Merge branch B1 into branch B2 ! you cannot undo a hard reset
Changes to tracked files
git checkout <B2> Revert the last commit git diff
git merge <B1> git revert HEAD
Creates a new commit Changes between ID1 and ID2
Create branch based on HEAD
Revert specific commit git diff <ID1> <ID2>
git branch <BRANCH>
Create branch based on another git revert $id History of changes
Creates a new commit git log
git checkout <new> <base>
Fix the last commit
Delete a branch git commit -a --amend History of changes with files changed
git branch -d <branch> after editing the broken files git whatchanged
Checkout the ID version of a file Who changed what and when in a file
master is the default development branch git checkout <ID> <file> git blame <file>
origin is the default upstream repository A commit identified by ID
HEAD is the current branch
git show <ID>
A specific file from a specific ID
git diff <ID>:<FILE>
Licensed under Creative Commons Attribution-Share Alike
3.0 Unported License: creativecommons.org/licenses/- All local branches
git branch
by-sa/3.0/ star "*" marks the current branch
Search for patterns
Original by pastjean: github.com/pastjean/git-cheat-sheet git grep <pattern> [path]

By Pierre-Alexandre St-Jean - http://stjean.me/


Re-arranged by Wall-Skills.com - Informative 1-Pagers

You might also like