|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Version Control |
| 4 | +# Distributed VC |
| 5 | +# Advantages of DVC and Git |
| 6 | + |
| 7 | +# Structure of git (.git, sha1, blob, etc.) |
| 8 | +# Object types (blob, tree, commit, tag (HEAD,branch)) |
| 9 | +# Layers (working tree, index, repo, remote) |
| 10 | + |
| 11 | +# How to get git manpages |
| 12 | + |
| 13 | +# Configure Git |
| 14 | +git config --global user.name "Your Name Here" |
| 15 | +git config --global user.email "[email protected]" |
| 16 | + |
| 17 | +# Turn folder into git repo |
| 18 | +mkdir repo1 |
| 19 | +cd repo1 |
| 20 | +git init |
| 21 | + |
| 22 | +echo "This is in the file" > file1 |
| 23 | + |
| 24 | +# Check status of index |
| 25 | +git status |
| 26 | +git status -s |
| 27 | + |
| 28 | +# Add files to the index |
| 29 | +git add file1 |
| 30 | + |
| 31 | +# Move files from index to repo |
| 32 | +# git commit |
| 33 | +#git commit -a |
| 34 | +git commit -m "first commit of repo" |
| 35 | + |
| 36 | +echo "This is also in the file" >> file1 |
| 37 | +git status -s |
| 38 | +git add file1 |
| 39 | +git status -s |
| 40 | +git commit -m "updated file1" |
| 41 | + |
| 42 | +# View log |
| 43 | +git log |
| 44 | + |
| 45 | +# Checkout command (detached head) |
| 46 | +git checkout `git log --pretty=format:%H | tail -1` |
| 47 | +cat file1 |
| 48 | +git checkout master |
| 49 | + |
| 50 | +# Diff |
| 51 | +git diff file1 |
| 52 | +git diff `git log --pretty=format:%H | tail -1` file1 |
| 53 | +git diff HEAD~1 file1 |
| 54 | + |
| 55 | +# Branching |
| 56 | +git branch |
| 57 | +git branch feature1 |
| 58 | +git branch |
| 59 | +git checkout feature1 |
| 60 | +git branch |
| 61 | + |
| 62 | +echo "Yet another thing in this file" >> file1 |
| 63 | +echo "Stuff in a new file" > file2 |
| 64 | + |
| 65 | +git status -s |
| 66 | +git add file1 |
| 67 | +git add file2 |
| 68 | +git commit -m "new file and updated previous file" |
| 69 | + |
| 70 | +git log |
| 71 | + |
| 72 | +git checkout master |
| 73 | +git branch |
| 74 | + |
| 75 | +# Merging |
| 76 | + |
| 77 | +git log |
| 78 | +git merge feature1 |
| 79 | +git branch -d feature1 |
| 80 | +git branch |
| 81 | + |
| 82 | +# Cloning |
| 83 | + |
| 84 | +cd ../ |
| 85 | +git clone repo1 repo2 |
| 86 | +cd repo2 |
| 87 | +git log |
| 88 | + |
| 89 | +# Pulling from remote |
| 90 | + |
| 91 | +cd ../repo1 |
| 92 | +echo "Yet another line in a file" > file3 |
| 93 | +git status -s |
| 94 | +git add file3 |
| 95 | +git commit -m 'a third file added to the project' |
| 96 | +git log |
| 97 | + |
| 98 | + |
| 99 | +cd ../repo2 |
| 100 | +git log |
| 101 | +git pull |
| 102 | + |
| 103 | +# Adding a remote |
| 104 | +cd ../repo1 |
| 105 | +git remote add child ../repo2 |
| 106 | +git pull child master |
| 107 | + |
| 108 | +# git push |
| 109 | + |
| 110 | +# Off to github |
| 111 | + |
| 112 | +# Tagging |
| 113 | + |
| 114 | +git tag |
| 115 | +git tag -a v2.0 -m 'Version 2.0' |
| 116 | +git tag |
| 117 | + |
| 118 | +git tag -a v1.0 -m 'Version 1.0' `git log --pretty=format:%H | tail -2 | head -1` |
| 119 | +git diff v1.0 v2.0 |
| 120 | +git diff v1.0 file1 |
| 121 | + |
| 122 | +# Git GUI |
| 123 | + |
| 124 | + |
| 125 | +# Cleanup |
| 126 | +cd ../ |
| 127 | +rm -rf repo1 repo2 |
0 commit comments