GIT Chapter 1 Flashcards
(30 cards)
What is a ‘Local Repository’ ?
Files which are stored on your laptop in Git is called Local Repository.Modifications done here in files - Git will maintain history of changes
what is the purpose of the command ‘CLONE’ ?
Used to checkout code from remote repository
what is a ‘Remote Repository’ ?
The repository on server is called ‘Remote Repository’
How do we copy or checkout code from server ?
We can ‘checkout’ code from server ( remote reposiotry ) using the CLONE command.
What are ‘HEADS’ ?
This is just a term - by which Git maintains commit history for each branch.
How do we see different ‘BRANCHES’ ?
Use the command:
‘git branch’
what are ‘TAGS’ ?
This is a useful feature - which allows us to create a SNAPSHOT of code ‘at that point in time’.
This feature is typically used to maintain production released code - so that if ever we cant to go back to a specific version - using this feature we can.
How do I see the different tags in my code ?
Use the command:
tag -l
How do I create a new branch from an existing tag ?
Typically on first cloning from remote repository we will be in ‘master’.
Now to create a branch - xyz from a specific tag - tag123 - use the command:
git checkout -b xyz tag123
This will create a new branch - xyz
Unlike svn - you will not see any folder for new branch.
How does a ‘BRANCH’ in Git differ from SVN ?
There is no folder for a branch.
Only thing is in gitbash - it would show which branch you are working on
when you list all the branches - the branch that you are currently in - will be shown with an *
what is the advantage and use of GIT ?
It is distributed ( DVCS ) - so everyone has the completes repository on their desktop.
Commits can be made locally - ‘offline’
How do I create a ‘Repo’
Use the command :
git init
This will create a local repo.
This is the starting point
what do we mean by ‘UNTRACKED’ ?
Files that are not under GIT control are ‘Untracked’
what does the command ‘git status’ do ?
It is used to tell us what has changed since last commit.
How do I find changes since my last commit ?
Use the command :
git status
How do I see commit history ?
Use the command:
git status
what is the typical workflow in GIT ?
One flow is :
Add a file as ‘untracked’
Add file to ‘staging area’
Commit
OR
Modify existing file
Add changed file to ‘staging area’
Commit
Explain the ‘untracked’ details in workflow
Lets say you are in a repository.
You create a new file .
Now when you run ‘git status’ - it tells us that we have untracked file present.
How do I start ‘tracking’ an ‘untracked’ file ?
To start tracking - simply use the command:
git add
This will change the file from ‘untracked’ to ‘tracked’
The file is now in staging area.
Running the command - git status :
tells us that file is staged and needs to be committed …
How do I commit untracked files ?
To commit ‘tracked’ files use the command:
git commit -m ‘’
So this completes the workflow step 3 - commiting files in staging
what is ‘MASTER’
xxxx
Can I directly commit ‘untracked’ files ?
No - Git will ignore the attempt to commit untracked files.
So first the files must be placed in staging area and only then will git commit work.
How do I find files that have been modified but not committed ?
Using the command : git status
This tells us the names of the files that have been modified.
How do I undo changes to modified files - essentially revert my changes in GIT ?
Use the command:
git checkout –
This will essentially revert your changes made in file.