Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: trayburn/GITLabs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: improving/GITLabs-CATechnologies
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.

Commits on Jan 22, 2015

  1. Handout

    trayburn committed Jan 22, 2015
    Copy the full SHA
    ac74aaf View commit details
  2. notes init commit

    JingWangCA committed Jan 22, 2015
    Copy the full SHA
    950180b View commit details
  3. working locally

    Vinh Luu committed Jan 22, 2015
    Copy the full SHA
    754cede View commit details
  4. Add the Git Simple Cycle

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    8be888e View commit details
  5. the beginning of the end

    jrod454 committed Jan 22, 2015
    Copy the full SHA
    2a6a6ea View commit details
  6. Handout.md

    tej committed Jan 22, 2015
    Copy the full SHA
    2eee1fb View commit details
  7. Add overview of Git Structures

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    d8f7016 View commit details
  8. Introduction to git

    Emelda committed Jan 22, 2015
    Copy the full SHA
    d34a9fa View commit details
  9. Install required software

    Vinh Luu committed Jan 22, 2015
    Copy the full SHA
    d760c3e View commit details
  10. Handout.md

    tej committed Jan 22, 2015
    Copy the full SHA
    578fc59 View commit details
  11. first save

    casfr03 committed Jan 22, 2015
    Copy the full SHA
    03b3d65 View commit details
  12. command line notes

    JingWangCA committed Jan 22, 2015
    Copy the full SHA
    3631b1c View commit details
  13. Add overview of Git Structures (align)

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    80afaea View commit details
  14. This is for my wiki

    sakhtar01 committed Jan 22, 2015
    Copy the full SHA
    fb6036a View commit details
  15. Merge pull request #5 from JingWangCA/master

    Jing Wang's first commit to the handout
    trayburn committed Jan 22, 2015
    Copy the full SHA
    3c07724 View commit details
  16. merged with master

    jrod454 committed Jan 22, 2015
    Copy the full SHA
    aa491cd View commit details
  17. Merge in my changes with Jing's base document

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    08e97db View commit details
  18. Syed Wiki for GIT

    sakhtar01 committed Jan 22, 2015
    Copy the full SHA
    627408c View commit details
  19. Second update

    Emelda committed Jan 22, 2015
    Copy the full SHA
    e3a429f View commit details
  20. reformatted after the merge

    jrod454 committed Jan 22, 2015
    Copy the full SHA
    dd8ba78 View commit details
  21. Merge with gitlabs-catechnologies

    Emelda committed Jan 22, 2015
    Copy the full SHA
    15b9622 View commit details
  22. Merged with Jing

    casfr03 committed Jan 22, 2015
    Copy the full SHA
    833e10a View commit details
  23. combined notes

    Vinh Luu committed Jan 22, 2015
    Copy the full SHA
    31d1751 View commit details
  24. deleted

    Emelda committed Jan 22, 2015
    Copy the full SHA
    561b1f1 View commit details
  25. Copy the full SHA
    c326c2c View commit details
  26. Added Caleb's modifications

    jrod454 committed Jan 22, 2015
    Copy the full SHA
    23071b5 View commit details
  27. Add info for alias, branch and status

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    4fa7c39 View commit details
  28. added 'do not do' section

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    78ef69e View commit details
  29. added 'stupid git tricks' section

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    92ba5b8 View commit details
  30. Added Tim's suggjested change

    jrod454 committed Jan 22, 2015
    Copy the full SHA
    5610d1c View commit details
  31. merge with Tej

    Vinh Luu committed Jan 22, 2015
    Copy the full SHA
    4ec075d View commit details
  32. deleting orig files

    Vinh Luu committed Jan 22, 2015
    Copy the full SHA
    45f408b View commit details
  33. Integrated notes from group

    sakhtar01 committed Jan 22, 2015
    Copy the full SHA
    8bcf874 View commit details
  34. More details

    Emelda committed Jan 22, 2015
    Copy the full SHA
    d6607e6 View commit details
  35. Add comments to Git Simple Cycle

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    2801dec View commit details
  36. Copy the full SHA
    b7fced5 View commit details
  37. More details

    Emelda committed Jan 22, 2015
    Copy the full SHA
    5b7c597 View commit details
  38. Add comments to Git Simple Cycle and add Git quirks

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    5f4deaa View commit details
  39. More details-fixed typo

    Emelda committed Jan 22, 2015
    Copy the full SHA
    42a90e9 View commit details
  40. Add to combined notes 1

    casfr03 committed Jan 22, 2015
    Copy the full SHA
    8db225e View commit details
  41. Added git commands

    sakhtar01 committed Jan 22, 2015
    Copy the full SHA
    e1e661f View commit details
  42. Added git commands

    sakhtar01 committed Jan 22, 2015
    Copy the full SHA
    34bb376 View commit details
  43. Merge pull request #8 from jrod454/master

    the beginning of the end
    trayburn committed Jan 22, 2015
    Copy the full SHA
    9d61a36 View commit details
  44. Tim's Aliases

    trayburn committed Jan 22, 2015
    Copy the full SHA
    0785573 View commit details
  45. More details

    Emelda committed Jan 22, 2015
    Copy the full SHA
    ab6611f View commit details
  46. This is for my wiki

    sakhtar01 committed Jan 22, 2015
    Copy the full SHA
    2c7e8a5 View commit details
  47. Add the Git Simple Cycle

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    fb59be9 View commit details
  48. Add overview of Git Structures

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    49a0ac1 View commit details
  49. Add overview of Git Structures (align)

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    709d442 View commit details
  50. Add info for alias, branch and status

    Jeff Bogue committed Jan 22, 2015
    Copy the full SHA
    593e787 View commit details
Showing with 516 additions and 0 deletions.
  1. BIN GIT Workshop.pptx
  2. +516 −0 handout.md
Binary file added GIT Workshop.pptx
Binary file not shown.
516 changes: 516 additions & 0 deletions handout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,516 @@
#GIT Notes
##This is the Git notes from the 1-day training session at ImprovingEnterprises on Jan 21-22, 2015.

## Git Overview
### What is GIT?
* GIT is DVCS (distributed version control).
* GIT is File system based version control.

###Supported features vs other version control systems

1. Commit - YES
2. Merge - NO
3. Diff - NO
4. Edit - NO

####Common Practice to be followed

1. Write Code
2. Add `git add .`
3. Commit `git commit -m "msg"`
####Don't use or use with caution

1. `git gc`
2. `git prune`

####Git Internal

When you run `git init` in a new or existing directory, Git creates the .git directory and initializes GIT,
which is where almost everything that Git stores and manipulates is located.

1. Repository --> .git directory
2. Index --> information about staging area

###Merge and rebase model
1. git merge feature
2. git rebase
1. git merge branch
2. git rebase branch


##This is the Git notes from the 2-day training session at ImprovingEnterprises on Jan 21-22, 2015.

### Git Simple Cycle

1. Write Code
* Changes to files are stored in the local directory
1. `git add .`
* Changes are noted in the index area
1. `git commit -m "meaningful comment"`
* Changes are committed to the local repository
1. Repeat as often as you need

Variation on commit step:
`git commit -am "meaningful comment"`
* This will automatically "add" all previously tracked files to the repositorysitory. Currently untracked [new] files still need to be added with `git add .`.

### Overview of the Main Git Structures

```
DIR INDEX repository REMOTE
-------- -------- -------- --------
] WRITE
] CODE
--> add . -] (moves to index)
--> commit --] (moves to repository)
--> push ----] (moves to remote)
```


## Command Line Cheat Sheet
Verify Git installation
```
git --version
```
Get help with Git
```
git help
```
## Start (on set-up)
get products: git-scm, Atom.io, p4merge
(install GIT 2.2.2 or later)

right-click a directory for 'home base'
select "GIT base"
type 'git init' (first time only)

default text editor is VI (think UNIX)

Auto CR-LF = false (This is set by default. Do not change.)

When setting up your repository, maintain product structure and directories. Do `get init` from the root.

Show Aliases
```
git alias
```
Show all branches in repository
```
git branch
```
Show status of repository
```
git status
```
Discard changes made to a specific file and restore it
```
git checkout -- filename
```
Delete a branch from a repository
```
git branch -D branchName
```
View history of commits to the repositorysitory
```
git reflog
```
Invoke a graphical representation of reflog
```
gitk
```
Set user email
```
git config --global user.email "user_email"
```
Set user name
```
git config --global user.name "user_name"
```

General work cycle
* Write code
* . add
* commit

Checkout a branch
```
git checkout <branch_name>
```

Creating a new branch
```
git branch -b <new_branch_name>
```
* New branch name can include a backslash for git to use for organization.

Show all branches
```
git branch -a
```

Commit changes to local repository
```
git commit -m "commit_message"
```
Take off the most recent commit, but keep the changes
```
git reset HEAD
```
Take of the most recent *n* commits, but keep the changes
```
git reset HEAD~n
```
Take off the most recent *n* commits, and discard the changes
```
git reset --hard HEAD~n
```
type 'git init' (first time only)
git -scm will determine IDE (install 2.2.2 or later)

### Working with Remote Repository
get products: Atom.io, p4merge

default text editor is VI (think UNIX)
### Working Locally

General work cycle
* Write code
* . add
* commit

##General

To see prior history 'git history'

To undo prior commits use the command:
```
git revert <HEAD, sha, commitish, or HEAD~n>
```

First we need to add a remote location.

```
git remote add <name> <url>
```
* use -v (verbose) to see path for remotes

To remove a remote location:

...
git remote rm <name>
...

Note: 'origin' is commonly used for 'source of truth', can reference any other url

To download a copy of an exiting repository:
git clone origin

### Network commands

**PULL read only
**PUSH read/write
**FETCH read only (included in PULL and CLONE, rarely used alone)
**CLONE downloads a copy of an existing repository


Create a remote branch
```
git push <remote> localBranch:remoteBranch
```
Delete a remote branch
```
git push <remote> :branchToDelete
```
## Advanced topics
### Ignoring files in your repositorysitory
To ignore specific files, you need to create a .gitignore by running
```
touch .gitignore
```

### Cleaning generated files
Removing files that were recently created that you do not want to ever commit.
This is done in two steps:
```
git add .
git reset --hard HEAD
```

### Removing unwanted directories permanently

```
git filter-branch --tree-filter 'rm -rf lib' HEAD
```
This command modifies every commit in the current branch, back to the root, and changes it by removing the lib folder. As such, it will modify the commitish for all of those commits, and hence likely change public history. This is a good command when preparing a migrated repositorysitory, but a bad idea in most other cases.

### Stupid GIT Tricks
Get rid of trash files all in one go
```
git add .
git reset --hard HEAD
```
Create an easy undo strategy
```
git checkout -b <undoBranch>
<some possibly dangerous actions>
git checkout <branch you want to keep>
git checkout -D <branch you don't want to keep>
```
### Quirky Git Stuff
* You can't add an empty directory.

### Commands not to use
Do not invoke garbage collection
```
git gc
```
Do not prune orphaned nodes
```
git prune
```
Do not rebase nodes that have been pushed
```
git rebase -i <commitish>..<commitish>
```

### Required software:
```
1. GIT : http://git-scm.com/
2. Atom : https://atom.io/
known problem with installer if the TEMP and TMP variables are pointing to long path
3. p4merge P4Merge: Visual Merge Tool : http://www.perforce.com/downloads/Perforce/20-User?qt-perforce_downloads_step_3=1#product-10)
```


### Setup
Before we begin, ensure that following are installed

1. Download git and install from git-scm.com
1. Merge tool for use with git. In our case, we will go with p4merge visual merge tool (http://www.perforce.com/downloads/Perforce/20-User?qt-perforce_downloads_step_3=1#product-10)

##### Configure P4Merge
* git config --global diff.tool p4merge
* git config --global difftool.p4merge.cmd "p4merge.exe \$LOCAL \$REMOTE"
* git config --global merge.tool p4merge
* git config --global mergetool.p4merge.cmd "p4merge.exe \$BASE \$LOCAL \$REMOTE \$MERGED"
* git config --global mergetool.p4merge.trustExitCode true
* git config --global mergetool.p4merge.keepBackup false

1. AtomVCS editor can be downloaded from atom.io


### Git Configuration

Once the git is installed, set the user email address and the user name

```
git config -user.email <email_address>
git config -user.name <user_name>
```

### Creating a new repository

Create a new directory, go to the newly created directory and do git init.

```
$mkdir demo
$cd demo/
$ git init
Initialized empty Git repository in c:/source/demo/.git/
```
This will create a local master and all your current will be in the 'master'


### Working with branches

By default once the repository is created, you will automatically work in the "master" branch.
Recommendation is that any work should be carried out in a different branch (for ex: working, feature etc)

Creating a branch automatically switches the working branch to the new created branch (-b option creates a new branch)

```
$ git checkout -b working
Switched to a new branch 'working'
```
Now to add a file to the repository

* Create a file
* Add it to index (git add .)
* To check the status of the files under your repository (git status).
* Commit the file(s) to the local repository (git commit -m <comment>)

### Merging branches
Merging is Git's way of putting back together again a forked history. The git merge command lets you take the commits from one git branch and integrate them into a single branch.
Following command merge into the current branch. The current branch will be updated to reflect the merge, but the target branch will be completely unaffected.

```
git merge <branch>
```

### Deleting branches

```
git branch -d for deleting the obsolete target branch
```
### Clone a repository

It is possible to clone local repository or a remote one.

To clone a remote repository:

```
git clone https://github.com/<username>/<repositoryname>.git [<target_directory>]
```

By default it would create a directory named "repositoryname", if target is not specified.

To clone a local repository:

```
cd <parent_folder_of_the_repository_to_be_cloned>
git clone <repo>/.git <cloned_repo>
```

### Cleaning generated files
Removing files that were recently created that you do not want to ever commit.
This is done in two steps:
```
git add .
git reset --hard HEAD
```


## Discussions

Set up a github account. Can be free account with name/password. Good place for offsite backup of work, apart from where our 'source of truth' will be.

Remember git (like UNIX) is case-sensitive.


#Best Practices
Work from a **working** or **feature** branch, not **master**

Use 'git status' frequently to be sure where you are, what needs to be committed or removed (like .origin files)

Use 'git config' if you need to change some of your configuration.


## Tim's Aliases

### Simple Aliases

This is a list of all the simple aliases that Tim Rayburn (@TRayburn) keeps around to make his life easier, use what is useful to you, ignore the rest.

``` sh
# one letter shortcuts for the win
# --------------------------------

git config --global alias.a 'add -A'
git config --global alias.b 'branch'
git config --global alias.c 'checkout'
git config --global alias.cb 'checkout -b'
git config --global alias.f 'fetch'
git config --global alias.l 'log --pretty=oneline --abbrev-commit'
git config --global alias.r 'rebase --interactive HEAD~10'
git config --global alias.s '-p status'

# primary workflow related aliases
git config --global alias.pr 'pull --rebase'
git config --global alias.pom 'push origin master'
git config --global alias.rc 'rebase --continue'
git config --global alias.ra 'rebase --abort'
git config --global alias.ss '-p status -s'

# log related aliases
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
git config --global alias.lga "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --all"
git config --global alias.ll "log --pretty=oneline --abbrev-commit --max-count=15"
git config --global alias.lc "log --stat --summary"

# Colorization
git config --global color.branch "auto"
git config --global color.diff "auto"
git config --global color.status "auto"
git config --global color.branch.current "yellow reverse"
git config --global color.branch.local "yellow"
git config --global color.branch.remote "green"
git config --global color.diff.meta "yellow bold"
git config --global color.diff.frag "magenta bold"
git config --global color.diff.old "red bold"
git config --global color.diff.new "green bold"
git config --global color.status.added "yellow"
git config --global color.status.changed "green"
git config --global color.status.untracked "cyan"

# Other inherited aliases
git config --global alias.prune "fetch --prune"
git config --global alias.aliases 'config --get-regexp alias'
git config --global alias.amend 'commit --amend'
git config --global alias.bl 'blame -w -M -C'
git config --global alias.bra 'branch -rav'
git config --global alias.branches 'branch -rav'
git config --global alias.changed 'status -sb'
git config --global alias.filelog 'log -u'
git config --global alias.hist "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue) [%an]%Creset' --abbrev-commit --date=relative"
git config --global alias.last 'log -p --max-count=1 --word-diff'
git config --global alias.lastref 'rev-parse --short HEAD'
git config --global alias.lasttag 'describe --tags --abbrev=0'
git config --global alias.pick 'add -p'
git config --global alias.remotes 'remote -v show'
git config --global alias.stage 'add'
git config --global alias.stats 'diff --stat'
git config --global alias.sync '! git fetch upstream -v && git fetch origin -v && git checkout master && git merge upstream/master'
git config --global alias.undo 'reset head~'
git config --global alias.unstage 'reset HEAD'
git config --global alias.wdiff 'diff --word-diff'
git config --global alias.who 'shortlog -s -e --'
```

# Important GIT commands

git status // gives you all the status
git history // shows the history of git commands
git add . //add changes for staging area(index)
git alias // create alias for commands
git push origin localbranchname:newremotebranchname // I want to move this to some other branch and rename it
git checkout branch // checkout that branch
git lga --graphical display of branches
git mergetool // brings up the git merge tool
git rebase --continue (rebase continue)
git commit --amend
git push origin :remotebranchname // delete a remote branch - This is how you delete from your source of truth. Leave the localbranchname empty
git clone <url /dir of the remote repo> localrepositoryname // clone a branch
git rebase branchname
git branch -D working // delete branch from local repo
git push -u origin branchname
git init // initializes git directory
git config --global user.email "syed.akhtar@ca.com"
git config --global user.name "Syed Akhtar"
git commit -m "first commit"
git checkout -b branchname // creating new branch
git add -A . // Commit the files are actually deleted
git log working
git log master
. setup.sh
atom .
git c working
git merge feature
git reset HEAD~1
git status
git lga
git reflog
git reset HEAD~1
git reset --hard HEAD~1

## GIT Information and Administration

https://github.com/
https://github.com/improvingenterprises/GITLabs-CATechnologie
http://git-scm.com
http://git-scm.com/download/win
https://atom.io/