kenvantruong
5/27/2018 - 4:39 PM

Git

// Open Visual Studio Code IDE
: code .

// Check The Verison
: git --version
// Get Help
: git help 
// Git Help Page
: git help commit
// List All Settings
: git config --list 
// View One Setting
: git config user.email 

/** ------Config Our Username and Email (Create Account) ------**/

// Set Username
: git config --global user.name "Ken Truong" 
// Set Email
: git config --global user.email "kenvantruong@gmail.com" 


/** ------Navgiate inbetween folders ------**/

// Check location of Git
: pwd

// Go Forward to a Folder
: cd foldername

// Go Back
: cd..

// Create folder
: mkdir

// Create files
: touch

// Copy file to another destination
: cp ~/Downloads/picture.png .

// List all folders
: ls

// List Hidden Files
: ls -la

/** ------START GIT PROJECT ------**/ 
/**
Everytime we create a file, there are 3 steps:       
1) Working Copy = Created on Local Computer          -> git add filename.html 
2) Staging Area = Git Add . is in the Staging Area.  -> git commit -m "Message Here"
3) Repository = Git keeping track of the files.
**/ 

// Step 1: Navgatie to Project folder---------

// Start Get Project
: git init

// Add changes to your project
: git add .

// Add changes of single file to Git (Adding it to the staging Area)
: git add sample.html

// Snapchat a point and time of Git --Note: every commit is a pont and time you can go back to.
: git commit -m "Message Here" // Put a message of what you done. So you could go back to it.

// Hard Commit => Commit all files without staging area. Straight to commit everything.
 git commit -am "Clean up the HTML comments"

// View git logs
: git log

// View Single User logs
: git log --author="firstName"

// Git Status
: git status

// Show the different of the changes. First commit and the latest
: git diff

// Show different in staging area
: git diff --stage

// Remove File
: git rm sample.html // Note: you have to commit after deleting files

// Rename File on computer locally (Longer Way)
: git add newfile.html
: git rm  oldfile.html
: git commit -m "renamed file"

// Rename file on Git (Easiest way)
: git mv sample.html newSample.html

// Moving files
: git mv sample.html folderName/
  
  
 
// Undo Changes - When Mistake is made
 git checkout -- index.html

// Undo Commit Files Back
: git checkout 67**34**c4 <-commit #




Git
Working Copy => Staging Area => Repository


Steps to use Git:

1. Navgatie to Project folder : cd, ls, pwd
2. Check : git status
3. Start: git init
4. Add All: git add .
5. git commit -m "Message Here"
   git commit -am "Message Here" // Warning: This will commit every single file. Only use for simple edit!
   
Working Copy <= Staging Area - Bring it back down   
   git reset HEAD index.html

Undo Changes - When Mistaken
   git checkout -- index.html // Undo Changes - When Mistake is made
   
Remove File
: git rm sample.html // Note: you have to commit after deleting files

Undo Commit Files Back (Getting Old Verisons back)
: git checkout 679fa0ec4 -- index.html // Note will have to git commit -am "note" After.
Steps to use Git on Github:

1. cd, ls, pwd // Navgatie to Project folder:
2. git status
3. git init
4. git add .
5. git commit -m "noteText"
6. git log 
7. git remote add "nameYourRepo" https://github.com/kenvantruong/YourProject.git
8. git remote
9. git push -u "nameYourRepo"
Note: fatal: 'origin' does not appear to be a git repository
Answer: push an existing repository from the command line
10. git remote add origin git@github.com:kenvantruong/nameYourProject.git
11. git push -u origin master

Erro: Please make sure you have the correct access rights and the repository exists.
error: git remote -v
Remove remote - git remote remove real-staterepo

12. enter your github username
13. enter your github password