Git is a version Control system for tracking changes in computer files
Accessible |
Everyone can contribute! |
Distributed |
Enable large and distributed teams to collaborate |
History |
Every change is tracked |
Repository |
Database where files are stored and managed |
Server |
The computer that stores your repo |
Client |
The computer you use to connect to the server |
Local Copy |
Repo files you keep on your computer to make changes |
Master |
The primary location for code in the repo |
Branch |
An independent line of development |
Fork |
A copy of the repo |
Merge |
Add changes from one file into another |
$ git --version
** No need to type in the $, this just indicates it is a shell command.
$ git config --list
$ git config --global user.name "First Name Last Name"
$ git config --global user.email "email@example.com"
$ git config --list
$ ls
$ cd ~/
$ mkdir my-first-repo
$ cd my-first-repo
$ git init
$ git status
$ touch my-file.txt
$ ls
$ git add my-file.txt
$ git status
$ git commit -m "initial commit"
init |
Create an empty Git repository or reinitialize an existing one |
config |
Get and set global or repo options |
status |
Show the working tree status |
add |
Adds the file contents to the index |
commit |
Add the changes from one file to another, bringing them up-to-date |
$ git log
commit [UNIQUE HASH] (HEAD -> master)
Author: Your Name
Date: [DATE]
initial commit
(END)
$ git checkout my-file.txt
$ git add my-file.txt
$ git reset HEAD my-file.txt
$ git add my-file.txt
$ git commit -m "changing and commiting text"
$ git log
$ git reset HASH or git reset --hard HASH
$ type %userprofile%\.ssh\id_rsa.pub
$ cat ~/.ssh/id_rsa.pub
➜ ~ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAA.....
$ ssh-keygen -t rsa -C "your.email@example.com" -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/yourname/.ssh/id_rsa):
Created directory '/Users/yourname/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/yourname/.ssh/id_rsa.
Your public key has been saved in /Users/yourname/.ssh/id_rsa.pub.
The key fingerprint is:
9b:7c:c0:e2:62:74:bf:6b:85:4f:61:8f:d31:0:ef:b7 your.email@example.com
The key's randomart image is:
+--[ RSA 2048]----+
| . |
| o + . |
| . o So B |
| . o +. += + . |
| o .. E +. o |
| . . B . o |
| .o . |
+-----------------+
$ pbcopy < ~/.ssh/id_rsa.pub
$ type %userprofile%\.ssh\id_rsa.pub | clip
$ cat ~/.ssh/id_rsa.pub | clip
$ git clone PASTE SSH HERE
$ ls
$ cd NAME-OF-PROJECT-OR-FILE
$ git checkout -b BRANCHNAME
$ git branch BRANCHNAME
Open up the README.md file using your favorite code editor.
$ git status
modified: README.md
$ git add README.md
$ git status
modified: README.md
$ git commit -m "details of the change made"
$ git status
On branch [BRANCHNAME]
Your branch is ahead of 'origin/[BRANCHNAME]' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
$ git push
fatal: The current branch test-branch has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin [BRANCHNAME]
$ git push --set-upstream origin [BRANCHNAME]
Branch [BRANCHNAME] set up to track remote branch test-branch from origin
$ git checkout master
$ git pull
$ git status