* Contents below are summary of the video above.
What is Git?
- Version Control System (VCS) for tracking changes in computer files
- Created in 2005 by Linus Torvalds, creator of Linux
- Distributed version control : de-centralized (developers don't have to be in the same network)
- Coordinates work between multiple developers
- Who made what changes and when
- Revert back at any time, as long as it's commited
- Have Local & remote repository
Concepts of Git
- Keeps track of code history
- Takes "snapshots" of your files
- You decide when to take a snapshot by making a "commit"
- You can visit any snapshot at any time
- You can stage files before committing
How to start Git
1. $ git init
2. $ git config --global user.name 'name'
3. $ git config --global user.email 'email'
4. $ git add <file> // run after modifying & saving the file
5. $ git commit
** save the file -> add -> commit -> push
How to make Git ignore certain files
1. $ git touch .gitignore
2. Type the file name that you want to ignore in the file .gitignore
3. $ git add .gitignore
** To ignore a folder, type /foldername
** To ignore all txt files, type *.txt
BASIC COMMANDS
LOCAL
$ git init
// initialize local Git Repository
// Creates .git folder, hidden by default
// After initializing, can start running other commands
$ git add <file>
// Add file(s) to Index (staging area)
// File(s) get ready for commands
// Can run as many times as you need to before committing
$ git add .html // Add every html files
$ git add . // Add all the files in the folder
$ git status
// Check status of working tree
// See what's in the staging area
// Display differences between the working tree and the staging area (index)
$ git commit
// Commit changes in index
// Take everything in the index(staging area) and put it into the local repository
$ git commit -m 'comment' // Skip editing commit part
$ git touch <file>
// Create the file in the current index (folder)
$ git config --global user.name 'name'
// Add my name
$ git config --global user.email 'email'
// Add my email
$ git rm --cached <file>
// Remove the file from Git
$ clear
// Clear the console
$ git branch <branchName>
// Create a branch
$ git checkout <branchName>
// Switch to another branch
// Make sure to commit everything before switching
$ git merge <branch>
// Merge the branch to current branch
REMOTE REPOSITORIES
$ git push
// Push to remote repository
// Take local repository and push it to a remote repository (i.e. github)
// Have to add a remote service and credentials in advance
$ git push -u origin master
// Push to remote repository for the first time
$ git pull
// Pull latest from remote repository
$ git clone
// Clone repository into a new directory
$ git remote
// Shows all the remote repositories
$ git remote add origin <remote repository address>
// Address can be found @github
'TIL: Today I Learned' 카테고리의 다른 글
[TIL] 20201107 HTML: Forms & Tables (0) | 2020.11.07 |
---|---|
[TIL] 20201106 HTML: Next Steps & Semantics (0) | 2020.11.07 |
[TIL] 20201101 HTML: The essentials (2) (0) | 2020.11.02 |
[TIL] 20201028 HTML: The essentials (1) (0) | 2020.10.28 |
[TIL] 20201021 Introduction to Web Development (0) | 2020.10.21 |