README.md 2.44 KB
Newer Older
Chris Bills's avatar
Chris Bills committed
1 2 3
### Getting Started with GitLab

1. Generate an SSH keypair for GitLab (optional)
Chris Bills's avatar
Chris Bills committed
4
  * `ssh-keygen -t rsa -b 2048 -f ~/.ssh/gitlab.cels.anl.gov`
Chris Bills's avatar
Chris Bills committed
5 6 7 8 9 10 11 12 13

1. Add your SSH public key to your account on GitLab:
  1. Browse to: https://gitlab.cels.anl.gov/profile/keys
  1. Click Add SSH Key (top-right)
  1. Set the title to something meaningful
  1. Copy your public key and paste it into the Key field
  1. Click Add Key

1. Add an entry for GitLab in your ~/.ssh/config file (Optional but very convenient)
Chris Bills's avatar
Chris Bills committed
14
  * This will allow you to type something like `git clone gitlab:namespace/project.git` without needing to pass a username, fqdn, or ssh identity to git
Chris Bills's avatar
Chris Bills committed
15 16 17 18 19 20 21

```
Host  gitlab
  User              git
  Hostname          gitlab.cels.anl.gov
  IdentityFile      ~/.ssh/git.cels.anl.gov
```
Chris Bills's avatar
Chris Bills committed
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

### bash-functions

A file that contains some example functions that can be helpful when working with git.

1. `gits [#]` - a function that displays a brief summary of changes and the previous 5 log messages and hash commits. If an optional number is provided, it will display that many log messages.

### bash-git_prompt

An example addition to the bash prompt that will show you which branch you currently have checked out, and what its status is.

#### Symbol meanings:
* `>` - Local branch is ahead of the branch it is tracking
* `<` - Local branch is behind the branch it is tracking
* `!` - Local and remote branches have diverged
* `+` - There is at least 1 local `stash`
* `?` - There are files in the git working directory that are untracked

Example:

`fool [git-tips:master?+>]$` (only imagine it in color... yeah, real helpful, I know...)

This means the local branch `master` is ahead of the remote branch it is tracking, there is at least one stash, and there are untracked files present.
45 46 47 48 49 50 51 52 53 54 55 56 57

### git-aliases

A collection of useful git aliases. These can be placed in `~/.gitconfig` (recommended) or within a project's git config (not recommended).

* `co` - Alias for `checkout`, easier and quicker to type
* `last` - Display information about the most recent commit
* `unstage` - Reverse a `git add <file>` with `git unstage <file>`
* `ls` - list all the files currently tracked by git
* `vis` - display a pretty listing of log messages with a graph of the branching
* `today` - (Requires git v1.8+) displays log of commits since yesterday; e.g. today's commits
* `squash` - Does an interactive rebase of the previous # commits; useful for squashing commits
* `stashed` - Display information about stashes