How to use Git Flashcards
What is Git
Git is a version control system.
Git helps you keep track of code changes.
Git is used to collaborate on code.
Check what version of Git you are using
git –version
What does Git do
-Manage projects with Repositories
-Clone a project to work on a local copy
-Control and track changes with Staging and Committing
-Branch and Merge to allow for work on different parts and versions of a project
-Pull the latest version of the project to a local copy
-Push local updates to the main project
How do you work with Git
-Initialize Git on a folder, making it a Repository
- Git now creates a hidden folder to keep track of changes in that folder
When a file is changed, added or deleted, it is considered modified
-You select the modified files you want to Stage
-The Staged files are Committed, which prompts Git to store a permanent snapshot of the files
-Git allows you to see the full history of every commit.
-You can revert back to any previous commit.
-Git does not store a separate copy of every file in every commit, but keeps track of changes made in each commit!
Why do you use Git?
-Over 70% of developers use Git!
Developers can work together from anywhere in the world.
- Developers can see the full history of the project.
- Developers can revert to earlier versions of a project.
Creating Git Folder
mkdir myproject
cd myproject
Initialize Git
git init
Initialized empty Git repository in /Users/user/myproject/.git/
Git Adding New Files
git status
On branch master
No commits yet
Untracked files:
(use “git add …” to include in what will be committed)
index.html
nothing added to commit but untracked files present (use “git add
When to do a Git Staging Environment
As you are working, you may be adding, editing and removing files. But whenever you hit a milestone or finish a part of the work, you should add the files to a Staging Environment.
What is a staged file
Staged files are files that are ready to be committed to the repository you are working on.
Add file to the Staging Environment
git add index.html
How to check if a file is staged
git status
How to add all files to be staged
git add –all
Shortcut: git add -A
What is git commit
Adding commits keep track of our progress and changes as we work. Git considers each commit change point or “save point”. It is a point in the project you can go back to if you find a bug, or want to make a change.
How to do git commit?
When we commit, we should always include a message.
Code
git commit -m “First release of Hello World!”
[master (root-commit) 221ec6e] First release of Hello World!
3 files changed, 26 insertions(+)
create mode 100644 README.md
create mode 100644 bluestyle.css
create mode 100644 index.html