We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
cre
Git Cheat Sheet
|
Git is the open source distributed version control system that facilitates GitHub activities on
your laptop or desktop. Thi
ue ouen mee atelier
Install
GitHub for Windows
[Link]
GitHub for Mac
[Link]
Git for All Platforms
[Link]
Git distributions for Linux and POSIX systems are avaliable on
the official Git SCM web site
Configure tooling
Configure user information for allocal repositories.
$ git config --global [Link] “[nane!
Sets the name you want attached to your commit transactions
$ git config -~global [Link] "[enail address)"
Sets the email you want attached to your commit transactions
$ git config --global [Link] auto
Enables helpful colorization of command line output
Branches
Branches are an important part of working with Git. Any
commits you make will be made on the branch you're currently
‘checked out” to. Use git status to see which branch that is
$ git branch [branch-nane]
Creates a new branch
$ git checkout [branch-name]
Switches to the specified branch and updates the
working directory
$ git merge [branch]
Combines the specified branch's history into the
current branch. This is usually done in pull requests,
butis an important Git operation.
$ git branch -d (branch-name]
Deletes the specified branch
ee eo scree atest Rel eo CTA aC
Create repositories
When starting out with a new repository, you only need to de it
‘once; either locally, then push to GitHub, or by cloning an
existing repository,
$ git init
Turn an existing directory into a git repository
$ git clone [url]
Clone (download) a repository that already exists on
GitHub, including all ofthe files, branches, and commits
The .gitgnore file
‘Sometimes it may be a good idea to exclude files from being
tracked with Git. This is typically done in a special fle named
itionore . You can find helpful templates for .gitignare
files at [Link]/gitignor
Synchronize changes
Synchronize your local repository with the remote repository
on [Link]
$ git fetch
Downloads all history rom the remote tracking branches
$ git merge
Combines remote tracking branch into c
nt local branch
$ git push
Uploads all local branch commits to GitHub
8 git pull
Updates your current local working branch with all new
commits from the corresponding remote branch on GitHub,
git pull Isacombination of git fetch and git mergeGitHub Git Cheat Sheet
Make changes
Browse and inspect the evolution of project files
§ git log
Lists version history for the current branch
$ git log --follow [file]
Lists version history fora fie, Including renames
$ git diff [first-branch]...[second-branch]
Shows content differences between two branches
$ git show [commit]
Outputs metadata and content changes of the specified commit
$ git add [file]
Snapshots the file in preparation for versioning
$ git commit -m "[descriptive message]"
Records fle snapshots permanently in version history
GitHub Flow
Redo commits
Erase mistakes and craft replacement history
S git reset (connit]
Undoes all commits after [commit], preserving changes locally
$ git reset --hard [commit]
Discards all history and changes back to the specitied commit
‘CAUTION! Changing history can have nasty side effects. If you
‘need to change commits that exist on GitHub (the remote),
proceed with caution. if you need help, reach out at
github. community or contact support.
Ccreste ‘feature’ branch trom ‘aster’
commit changes
Glossary
git: an open source, distributed version-control system
GitHub: a platform for hosting and collaborating on Git repositories
‘inaster’
Submit Pull Request
branch
Merge ‘feature’ branch ino ‘master!
QP
QP
Discuss proposed changes
‘and make more commits
commit: 2 Git object, a snapshot of your entire repository compressed into @ SHA
brane!
lightweight movable pointer to a commit
lone: a local version of a repository, including all commits and branches
remote: a common repository on GitHub that all team member use to exchange their changes
for!
a copy of a repository on Githlub owned by a different user,
pull request: a place to compare and discuss the differences introduced on a branch with reviews, comments, integrated
tests, and more
HEAD: representing your current working directory, the HEAD pointer can be moved to different branches, tags, or commits
when using git checkout
GitHub Training
Want to learn more about using GitHub and ¢
Email the Training Team or visit our web site for learning
event schedules and private class availability.
Reeser ur er
eaten ke