Introduction Flashcards
what is git?
- content tracker - tracks all the changes to the code
- Distributed version control system
what is a version control system?
Version control system means, you can go back in time to a previous version of the code since git stored it all
Why do we say DISTRIBUTED version control system?
DISTRIBUTED because, we will have a remote repository which will be stored in a server and a local repository which will be stored in the local machine of every developer.
Every developer has full copy of code base
What are the two repositories git has?
Local and Remote
Remote repository is usually a centralized server
When is a remote repository really useful?
When you want to take a backup of your code and when you are working as a team
What are the different stages in local repository?
The local repository actually consists of three stages. The working area, where all your active changes. Git doesn’t know what to do with them yet, it
just knows that these files contain some
updates.
The staging area contains new
changes that will soon be committed,
and then there are the committed files.
How is version control added to the project?
By adding commits
What is the procedure to commit?
The files that should be included in the
commit are first added to the staging area. A
commit gets created when a developer
actually commits those files.
for debian based distros, how do we install a package?
apt get
eg. sudo apt install git-all
How to initialize a a git repo?
git init
How does git know all of your changes and files?
Although we haven’t done anything with Git
yet, we initialized a Git repository in this
project/directory. so Git knows all of our files and their
changes.
What is committing in Git repository?
Storing changes in a local Git repository is called committing. With every commit, we save the current state of the repository
What are untracked files in the output of git status?
Untracked files. These are the files that Git
knows of. However, we haven’t told Git what
to do with them. We haven’t told it yet that
we want to add it to our local repository. Eg. Right now, we haven’t told Git what to do with the new
story1 .txt file. It might be that we don’t want
to add that story to our local repository at all.
What are the different areas in the local git repository?
- Working area
2.staging area - committed files area
Before committing a file, which area should you put the file in?
Staging area using the git add command
What is the command to run to commit the files that are in the staging area?
git commit -m
What happens when a new file is added or created in the working directory?
The file is known to be in the working area, and by default it is always untracked first, unless you tell git to track it
Which hidden folder gets created after initializing a git repo?
.git
Command to configure git username and email , to know who committed etc?
git user.name
git user.email
what command to make a file called notes.txt to take it out from git radar, basically we don’t want git to track this file?
echo notes.txt»_space; .gitignore
what happens when you add a file to .gitignore for the first time?
.gitignore file itself may be listed as untracked. It is a good practice to track the .gitignore file with git.
which command shows information about all the commits?
git log
What are all the information you can get from “git log”
- commit hash
- Author
- Date/Time of commit
- Commit message
What is a short way to see the git log, in case you don’t want to see all the details by default git log provides?
git log –oneline