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

Git Cheat Sheet: by Via

This document provides a cheat sheet summary of common Git commands for creating and managing local and remote Git repositories. It includes commands for initializing repositories, tracking changes, committing changes, branching and merging, and publishing changes to remote repositories. The cheat sheet covers the basic workflows for the core functions of Git including setting up a repository, making changes, committing changes, and collaborating through remote repositories.

Uploaded by

Owlie
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)
29 views1 page

Git Cheat Sheet: by Via

This document provides a cheat sheet summary of common Git commands for creating and managing local and remote Git repositories. It includes commands for initializing repositories, tracking changes, committing changes, branching and merging, and publishing changes to remote repositories. The cheat sheet covers the basic workflows for the core functions of Git including setting up a repository, making changes, committing changes, and collaborating through remote repositories.

Uploaded by

Owlie
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

Git Cheat Sheet

by Sam Collett (SamCollett) via cheatography.com/196/cs/104/

Create Git Repository

Git - History

Git - Remote Update / Publish

From existing directory

Show all commits

List remotes

cd project_dir

git log

git remote -v

git init

Short Format

Show information

git add .

git log --pretty=short

git remote show remote

From other repository

Patches

Add remote

git clone existing_dir new_dir

git log -p

git remote add path/url

git clone git://git hub.com/user/repo.git

Show file commits

Fetch changes

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

git log file

git fetch remote

Show directory commits

Fetch + merge

Git - Local Changes

git log dir/

git pull remote branch

Changed in working directory

Stats

Publish local to remote

git status

git log --stat

git push remote branch

Tracked file changes

Who changed file

Delete remote branch

git diff

git blame file

git push remote :branch

Add changed files

Publish tags

git add file1 file2 file3

Git - Merge/Rebase

Remove file

Merge branch into current

git rm file

git merge branch

Git - Branching/Tagging

git rm dir/ -r

Rebase into branch

List branches

(recursive under directory)

git rebase branch

git branch

See files ready for commit

git rebase master branch

Switch to branch

git diff --cached

Abort rebase

git checkout branch

Commit changes

git rebase --abort

Create new branch

git commit

Merge tool to solve conflicts

git branch new

git commit -m "My message"

git mergetool

Create branch from existing

git commit -a -m "My Message"

Conflicts against base file

git branch new existing

(tracked files only, auto add)

git diff --base file

Delete branch

Change last commit

Diff other users changes

git branch -d branch

git commit --amend

git diff --theirs file

Tag current commit

Revert changes to file

Diff your changes

git tag tag-name

git checkout -- file

git diff --ours file

Revert changes (new commit)

After resolving conflicts

git revert HEAD

git rebase --continue

git push --tags

Return to last committed state


git reset --hard HEAD

By Sam Collett (SamCollett)

Published 23rd November, 2011.

Sponsored by Readability-Score.com

cheatography.com/samcollett/

Last updated 1st June, 2014.

Measure your website readability!

www.texotela.co.uk

Page 1 of 1.

https://readability-score.com

You might also like