Understanding Git Flashcards
what is a Repository aka repo
Git Repo is a working space which tracks and manages files within a folder.
How does a repo work?
Anytime we want to to use Git with a project, app, etc we need to create a new git repository. We can have as many repos o n our machine as needed, all with separate histories and contents.
What is git status?
Gives us information on the current status of a git repository and its content.
What is git init?
it is used to create a new git repository.
Before we can do anything git-related, we must initialize a repo first
note : this is done once per project initialize the repo in the top-level folder containing your project.
A common mistake
:-Git tracks all Directories and all Nested Subdirectories
What not to do?
DO NOT INIT/initialize A REPO INSIDE OF A REPO
Before running git init, use git status to verify that you are nit currently inside of a repo
note:
make a folder, for a project and then initialize git in that folder don’t have a git repo on your desktop or your documents folder or the entire machine will be tracking everything. Have one repo per project
Always run git status
What is commit?
It is a checkpoint, or a snapshot of a project with new changes at a moment in time along with with a little message like (add top Navbar or Add fist row ) They are referred to as repo.
-Add a new feature then commit.-
Note:
Git commit is not Just about saving files, we have to male changes first, and save them to a file before we can even commit– NB–
SAVE CHANGES GROUP THEM TOGETHER INTO A COMMIT
Staging changes with Git Add
ADDING -> We use git add command to stage changes to be committed (its a way of telling git, please include this changes in our next commit.
How do use the git commit ?
We use the git commit command to actually commit changes from the staging area
Note:
we have to provide a commit message to summarize the changes. and work snapshotted in the commit.
what is the git commit -m command
git commit -m “my message”
Note:
The -m flag allows us to pass in an inline commit message, rather than launching a text editor
What is the git log command
Git log is a utility tool to review and read a history of everything that happens to a repository
git add
The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit. However, git add doesn’t really affect the repository in any significant way—changes are not actually recorded until you run git commit .
What is .git ignore ?
It is a command that we use, to not include some files that we don ‘t need in our main project.
What are some of the files that we .git ignore/ do not commit?
.Secrete API’s keys files (DS_STORE ON MAC)
.Operating systems.
.Dependancies & packages.
What is Branch?
(Are essential part of git )
Think of a branch as alternative timelines for a project
They enable us to create separate context where we can try new things, or even work on multiple ideas in parallel.
Note;
If we make changes on one brach, they do not impact the other branches (unless we merge the changes)
What is a Master Brach?
In 2020 Github renamed the default brach as master branch
Note:
in git, we are always working on a branch the default name is master branch