intro to git Flashcards
(11 cards)
what is system comands
Ls/pwd/cd
what is git and git repo
git is version control system for software development.
git repo is directory containing files and sub directory represented in .git file
commands for creating new rep / for convert an existing repo
1- git init repo_name
2- cd repo_name
3- git status
1- cd to the directory and use git init then track it by using git status
what is git workflow commands?
1- Add files to staging area using:
git add file_name
git add . -> for adding all changes even in sub directory
2- commit the file (git take a snapshot of the file) using:
git commit -m “message”
what is the commit structure?
1- commit: contain author, log message and commit time
2- tree: track the name and location of files and directories in the repo
3- Blob: binary large object includes any data and its a compressed snapshot of files content
4- git hash: 40 digits unique pseudi random number generated by hash function, if 2 files has the same hash then they are the same
what commands used to track the changes over such a file (5)?
git log show the hostory of commits for repo , used as:
1- git log
2- git log -x -> x in the number of commits
3- git log -x file_name
4- git log –since=”date’ –until=””
5- git show hash_no -> use 8 to 10 numbers only
what is the comparing commands (6)?
using git diff:
1- git diff -> compare between all the unstaged and the latest commit
2- git diff file_name -> compare between commited and local (unstaged) version
3- git diff –staged file_name -> compare between the staged copy and the last commit
4- git diff –staged -> compare all staged files with the last commit
5- git diff hash_no_1 hash_no_2 -> compare between 2 commits by using their hash numbers
6- git diff HEAD~1 HEAD -> compare between last commit and last commit -1
what is reverting and what is its main commands (3)?
- reverting in git is reverting the repo to the state before the last commit
- using: git revert HEAD or hash.
entering the command open a text editor , use Ctrl+o then Enter for saving and Ctrl+x for exiting - git revert –no-edit HEAD for not opening a text editor
- git revert -n HEAD for reverting without commiting
what to use to revert a single file and why?
git checkout HEAD – file_name
because git revert works on commits not inividual files
how to unstage a single file? all files?
- git restore –staged file_name
- file restore –staged