GIT Flashcards
Git
A Version Control System for tracking changes in files and coordinating work on them in team
Creating a repository
Git init
Check for changes
Git status
When there aren’t any files with changes in working directory then the directory is …..
Clean
Add a file to list of tracked files
Git add
When we add a file to list of tracked files using git add we’re said to stage it
When content is changed
The file is tracked but not staged anymore
Need to stage the file again using git add
Add all the un-staged files in the current directory (and deeper)
Git add .
When we run git add
Git captures a snapshot of the changes that we can make permanent by committing them to the repository
Committing changes to repository
Git commit -m “message”
Workflow
Make changes in the working directory
Use git add to stage them
Use git commit to save changes to repository
Check if git is installed
Open terminal
Git –version
Repository
Special type of directory that keeps track of the files within it
Git status
Tells if the working directory is clean
Tells what files are staged and ready to be committed
Tells what files are tracked but not staged
Tells what files are untracked
Git log
Git keeps track of every commit that we make
We can easily review them using git log
Brings up the commit history, where every commit is displayed with unique hash code
Git log
Pointer that point to the current commit
Git show HEAD
Go back to previous commit and put the working directory back to the state it was in that time
Git checkout [hash code/tag]
Can use either whole hash code or first seven characters
head detached
current commit isn’t the latest commit
get back to the latest commit
git checkout master
to add a tag to a commit (can help to memorize important commits)
git tag [parameter]
git tag
display previously added tags
allow us and others to work on different things, like features, at the same time
branches
default branch of every repository
master branch
git branch
show existing branches