intro to git Flashcards

(11 cards)

1
Q

what is system comands

A

Ls/pwd/cd

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is git and git repo

A

git is version control system for software development.
git repo is directory containing files and sub directory represented in .git file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

commands for creating new rep / for convert an existing repo

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is git workflow commands?

A

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”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is the commit structure?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what commands used to track the changes over such a file (5)?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the comparing commands (6)?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is reverting and what is its main commands (3)?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what to use to revert a single file and why?

A

git checkout HEAD – file_name
because git revert works on commits not inividual files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

how to unstage a single file? all files?

A
  • git restore –staged file_name
  • file restore –staged
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly