Version control allows you and your team to do two powerful things:
examples: CVS, Subversion, Perforce
examples: Git, Mercurial (Hg)
Open "Terminal"
Type "git" and hit enter.
Open "Git Bash"
Type "git" and hit enter.
-A -l
-Al
--all --oneline --verbose
man command
to get a description of the command .ssh
directory in your HOME
directory.pontiki2:~ student$ ls -Al ~/.ssh
ls: /Users/student/.ssh: No such file or directory
pontiki2:~ student$ ls -Al ~/.ssh total 8 -rw-r--r-- 1 student staff 171 Sep 24 12:33 known_hosts
pontiki2:~ student$ ssh-keygen -t rsa -C "your_email@example.com" # Creates a new ssh key, using the provided email as a label Generating public/private rsa key pair. Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase or press Enter] Enter same passphrase again: [Type passphrase again or press Enter]
Your identification has been saved in /Users/you/.ssh/id_rsa. Your public key has been saved in /Users/you/.ssh/id_rsa.pub. The key fingerprint is: 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com
The key's randomart image is:
+---[RSA 2048]----+
| .BoE |
| B O.o |
| o . = B *.o|
| o + = X O =+|
| . S X B o +|
| B . = . |
| + + . |
| o . |
| . |
+----[SHA256]-----+
$ pbcopy < ~/.ssh/id_rsa.pub
$ clip < ~/.ssh/id_rsa.pub
$ git config --global user.name "your name"
$ git config --global user.email "your_email@example.com"
$ git config --list user.name=your name user.email=your_email@example.com
pontiki2:~ student$ cd ~/
pontiki2:~ student$ mkdir my_first_repo pontiki2:~ student$ cd my_first_repo
pontiki2:my_first_repo student$ git init Initialized empty Git repository in /Users/student/my_first_repo/.git/ pontiki2:my_first_repo student$ git status On branch master Initial commit nothing to commit (create/copy files and use "git add" to track)
pontiki2:my_first_repo student$ echo 'Hello, world!' > hello_world.txt
pontiki2:my_first_repo student$ git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) hello_world.txt nothing added to commit but untracked files present (use "git add" to track)
pontiki2:my_first_repo student$ git add --verbose hello_world.txt add 'hello_world.txt'
pontiki2:my_first_repo student$ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: hello_world.txt
pontiki2:my_first_repo student$ date >> hello_world.txt pontiki2:my_first_repo student$ cat hello_world.txt Hello, world! Sat Sep 24 14:53:04 PDT 2016
pontiki2:my_first_repo student$ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: hello_world.txt Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: hello_world.txt
pontiki2:my_first_repo student$ git add --verbose hello_world.txt add 'hello_world.txt' pontiki2:my_first_repo student$ git status On branch master Initial commit Changes to be committed: (use "git rm --cached <file>..." to unstage) new file: hello_world.txt
pontiki2:my_first_repo student$ git commit -m 'Initial commit. Added `hello_world.txt` to my repo.' [master (root-commit) e921ba9] Initial commit. 1 file changed, 2 insertions(+) create mode 100644 hello_world.txt
pontiki2:my_first_repo student$ git status On branch master nothing to commit, working tree clean
pontiki2:my_first_repo student$ git log commit e921ba989bfcfcf9f646615663bf60b4b75c0c63 Author: Susan Student <student@example.com> Date: Sat Sep 24 15:12:00 2016 -0700 Initial commit. Added `hello_world.txt` to repo.
pontiki2:my_first_repo student$ git log --oneline e921ba9 Initial commit.
pontiki2:my_first_repo student$ echo 'testing undo of local changes' >> hello_world.txt pontiki2:my_first_repo student$ cat hello_world.txt Hello, World! Sat Sep 24 15:11:22 PDT 2016 testing undo of local changes
pontiki2:my_first_repo student$ git status On branch master Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: hello_world.txt no changes added to commit (use "git add" and/or "git commit -a")
pontiki2:my_first_repo student$ git checkout hello_world.txt
pontiki2:my_first_repo student$ cat hello_world.txt Hello, World! Sat Sep 24 15:11:22 PDT 2016
pontiki2:my_first_repo student$ git status On branch master nothing to commit, working tree clean
pontiki2:my_first_repo student$ echo 'undoing staged changes' >> hello_world.txt pontiki2:my_first_repo student$ cat hello_world.txt Hello, World! Sat Sep 24 15:11:22 PDT 2016 undoing staged changes
pontiki2:my_first_repo student$ git add -v hello_world.txt add 'hello_world.txt'
pontiki2:my_first_repo student$ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) modified: hello_world.txt
pontiki2:my_first_repo student$ git reset HEAD hello_world.txt Unstaged changes after reset: M hello_world.txt pontiki2:my_first_repo student$ git checkout hello_world.txt
pontiki2:my_first_repo student$ cat hello_world.txt Hello, World! Sat Sep 24 15:11:22 PDT 2016
pontiki2:my_first_repo student$ echo 'undoing staged and committed changes' >> hello_world.txt pontiki2:my_first_repo student$ cat hello_world.txt Hello, World! Sat Sep 24 15:11:22 PDT 2016 undoing staged and committed changes
pontiki2:my_first_repo student$ git add -v hello_world.txt add 'hello_world.txt' pontiki2:my_first_repo student$ git commit -m 'commit some stuff.' [master d123cdb] commit some stuff 1 file changed, 1 insertion(+)
pontiki2:my_first_repo student$ git log commit d123cdb0ee38dd70c3455651e54689658f65a4b1 Author: Susan StudentDate: Sat Sep 24 15:59:22 2016 -0700 commit some stuff commit e921ba989bfcfcf9f646615663bf60b4b75c0c63 Author: Susan Student Date: Sat Sep 24 15:12:00 2016 -0700 Initial commit. Added `hello_world.txt` to repo.
pontiki2:my_first_repo student$ git revert --no-edit d123cdb0ee38dd70c3455651e54689658f65a4b1
pontiki2:my_first_repo student$ cat hello_world Hello, World! Sat Sep 24 15:11:22 PDT 2016
pontiki2:my_first_repo student$ git checkout -b version2 Switched to a new branch 'version2'
pontiki2:my_first_repo student$ echo 'new line for v2' >> hello_world.txt pontiki2:my_first_repo student$ cat hello_world.txt Hello, World! Sat Sep 24 15:11:22 PDT 2016 new line for v2
pontiki2:my_first_repo student$ git status On branch version2 Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: hello_world.txt no changes added to commit (use "git add" and/or "git commit -a")
pontiki2:my_first_repo student$ git add hello_world.txt pontiki2:my_first_repo student$ git commit -m "Adding changes to version 2." [version2 6a69379] Adding changes to version 2. 1 file changed, 1 insertion(+) pontiki2:my_first_repo student$ git status On branch version2 nothing to commit, working tree clean
pontiki2:my_first_repo student$ git branch master * version2 # <-- this is the current version
pontiki2:my_first_repo student$ git checkout master Switched to branch 'master' pontiki2:my_first_repo student$ git branch * master version2 pontiki2:my_first_repo student$ cat hello_world.txt Hello, World! Sat Sep 24 15:11:22 PDT 2016
pontiki2:my_first_repo student$ git checkout version2 Switched to branch 'version2' pontiki2:my_first_repo student$ cat hello_world.txt Hello, World! Sat Sep 24 15:11:22 PDT 2016 new line for v2
pontiki2:my_first_repo student$ git checkout master
pontiki2:my_first_repo student$ git merge version2 Updating d4c7213..6a69379 Fast-forward hello_world.txt | 1 + 1 file changed, 1 insertion(+)
pontiki2:my_first_repo student$ git checkout master Already on 'master'
pontiki2:my_first_repo student$ sed -i~ 's/World/Folks/' hello_world.txt pontiki2:my_first_repo student$ cat hello_world.txt Hello, Folks! Sat Sep 24 15:11:22 PDT 2016 new line for v2
pontiki2:my_first_repo student$ git add hello_world.txt pontiki2:my_first_repo student$ git commit -m 'Modified hello_world.txt * Changed "World" to "Folks"' [master 323461d] Modified hello_world.txt 1 file changed, 1 insertion(+), 1 deletion(-)
pontiki2:my_first_repo student$ git checkout version2 Switched to branch 'version2'
pontiki2:my_first_repo student$ sed -i~ 's/World/you lot/' hello_world.txt pontiki2:my_first_repo student$ cat hello_world.txt Hello, you lot! Sat Sep 24 15:11:22 PDT 2016 new line for v2
pontiki2:my_first_repo student$ git add hello_world.txt pontiki2:my_first_repo student$ git commit -m 'Modify hello_world.txt * Changing the first line of hello_world.txt in version2.' [version2 98b3b40] Modify hello_world.txt 1 file changed, 1 insertion(+), 1 deletion(-)
pontiki2:my_first_repo student$ git merge master
Auto-merging hello_world.txt
CONFLICT (content): Merge conflict in hello_world.txt
Automatic merge failed; fix conflicts and then commit the result.
<<<<<<< HEAD
Hello, you lot!
=======
Hello, Folks!
>>>>>>> master
Sat Sep 24 15:11:22 PDT 2016
new line for v2
Well, hello there!
Sat Sep 24 15:11:22 PDT 2016
new line for v2
pontiki2:my_first_repo student$ git add hello_world.txt pontiki2:my_first_repo student$ git commit -m "Fixing hello_world.txt" [version2 5547b70] Fixing hello_world.txt
pontiki2:my_first_repo student$ git status On branch version2 Untracked files: (use "git add..." to include in what will be committed) hello_world.txt~ nothing added to commit but untracked files present (use "git add" to track)
pontiki2:my_first_repo student$ echo '*~' >> .gitignore pontiki2:my_first_repo student$ git status On branch version2 Untracked files: (use "git add <file>..." to include in what will be committed) .gitignore nothing added to commit but untracked files present (use "git add" to track)
pontiki2:my_first_repo student$ git add .gitignore pontiki2:my_first_repo student$ git commit -m 'Add .gitignore' [version2 c35f894] Add .gitignore 1 file changed, 1 insertion(+) create mode 100644 .gitignore
log/
/log/
pontiki2:my_first_repo student$ git checkout master Switched to branch 'master'
pontiki2:my_first_repo student$ git branch -d version2 error: The branch 'version2' is not fully merged. If you are sure you want to delete it, run 'git branch -D version2'.
pontiki2:my_first_repo student$ git merge version2 Updating 323461d..c35f894 Fast-forward .gitignore | 1 + hello_world.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .gitignore
pontiki2:my_first_repo student$ git branch -d version2 Deleted branch version2 (was c35f894). pontiki2:my_first_repo student$ git branch * master
pontiki2:my_first_repo student$ git remote add origin git@github.com:tamouse/my_first_repo.git pontiki2:my_first_repo student$ git push -u origin master
The authenticity of host 'github.com (192.30.253.113)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you want to continue connecting (yes/no)? yes
Delta compression using up to 4 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (26/26), 2.53 KiB | 0 bytes/s, done.
Total 26 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.
To git@github.com:tamouse/my_first_repo.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.
pontiki2:~ student$ git clone git@github.com:tamouse/jekyll.git Cloning into 'jekyll'... Warning: Permanently added the RSA host key for IP address '192.30.253.112' to the list of known hosts. remote: Counting objects: 30595, done. remote: Compressing objects: 100% (2/2), done. remote: Total 30595 (delta 0), reused 0 (delta 0), pack-reused 30593 Receiving objects: 100% (30595/30595), 9.18 MiB | 1.40 MiB/s, done. Resolving deltas: 100% (18545/18545), done. Checking connectivity... done.