Skip to content

Latest commit

 

History

History
133 lines (97 loc) · 8.04 KB

README.md

File metadata and controls

133 lines (97 loc) · 8.04 KB
Refresh Git Icon emoji-log Travis Build Status

Refresh your mind about everything about Git


About

This cheat sheet summarizes everything useful commonly used Git and GitHub for quick reference.

Install

Commands

Configure:

This is used to identify the commits you create:

$ git config --global user.name "[User Name]"

$ git config --global user.email "[e-mail]"

💡 Tip: Not necessary if you will use GitHub Desktop. Use git config -l to show all local git param.

Manage Repositories

Downloads a project and its entire version history

$ git clone [url]

Make Changes

File Status Lifecycle

File Status Lifecycle

Shows the status of changes as untracked, modified, or staged:

$ git status

List all remote and local branches:

$ git branch -a

Tells Git what files will be committed. It's necessary make it before of the $ git commit command:

$ git add [file-1] [file-2] [...] [file-n]

Add changes from all tracked and untracked file (new file, modified file and deleted file):

$ git add -A

💡 Tip: Use this in almost all cases. Find out more.

Add changes from only tracked files (modified file and deleted file):

$ git add -u

💡 Tip: This is useful when the new files are temporary and still not are in .gitignore. For example: log files.

Record changes to the local repository:

$ git commit -m "[summary message]" -m "[description message]"

💡 Tip: You can add many description messages, for example: $ git commit -m "Summary" -m "msg 1" -m "msg 2" -m "msg 3", etc.

Unstages the file, but preserve its contents: $ git reset <file>

💡 Tip: use only $ git reset for reset all files.

Discard changes in working directory

$ git checkout <file>

Troubleshooting

  • Git push results in “Authentication Failed”:

When you're using two-factor authentication you a personal access token is required to authenticate to GitHub over HTTPS with Git on the command line or the API. Find out more.

  • How to stop Google indexing my Github repository

The https://github.com/robots.txt file of GitHub allows the indexing of the blobs in the 'master' branch, but restricts all other branches. So if you don't have a 'master' branch, Google is not supposed to index your pages. Find out more: 1, 2, 3.

Commit Message Guidelines

Repository Management

Tricks

Git Code Management

List of alternatives source/git code management

References