Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gvelasq committed Jul 5, 2018
0 parents commit 54752de
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions git-cheatsheet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# git-cheatsheet

A cheatsheet of Git commands.

- [cd, ls](#navigate)
- [git init, git config](#git-setup)
- [editor](#git-editor)
- [git remote](#remote-branch)
- [git add, git commit](#add-and-commit)
- [delete local and remote branch](#delete-local-and-remote-branch)

## navigate

* navigate to a particular folder
```bash
cd "<path>"
```
* navigate up a folder
```bash
cd ..
```
* navigate to your home folder
```bash
cd
```
* list items in current folder
```bash
ls
```
* check git status
```bash
git status
```
* check git log
```bash
git log # too verbose
git log --oneline # condenses to a single line
git log --oneline -n 5 # prints only the last 5 commits
```

## git setup

* initialize a git repository
```bash
cd "<desired-path>"
git init
```
* check global and local git settings
```bash
git config --global -l
git config --local -l
```
* configure global git settings (cd anywhere)
```bash
git config --global user.name "<full-name>"
git config --global user.email "<email>"
git config --global core.editor "nano -w"
```
* configure local git settings
```bash
cd "<desired-path-for-local-settings>"
git config --local user.name "<local-full-name>"
git config --local user.email "<local-email>"
```

### git editor
* check editor version and run
```bash
nano --version
nano # exit nano with Ctrl-X
vim --version
vim
emacs --version
emacs
```

### remote branch
```bash
git remote -v
# the remote branch is named origin in this example
git remote add origin <https-origin-url>
git remote set-url origin <https-origin-url>
```

### add and commit
```bash
# add
git add <file.ext>
git add . # danger, this stages all changes
# commit
git commit -m "Message"
```

### delete local and remote branch
```bash
git branch -d <local-branch-name>
git push origin :<remote-branch-name>
```

0 comments on commit 54752de

Please sign in to comment.