Git Flashcards

1
Q

Add to .ignore

A

echo filename > .gitignore

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

Track multiple files

A

git add filename1 filename2

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

git add это

A

Кэширование файла.
Помещение файла в индекс.

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

What does git ls-files --stage display?

A

Lists files in the Git index (staging area) along with their mode bits, object names (SHA-1 hashes), and stage numbers.

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

List a summary of commit authors, display only the top 3 contributors

A

git shortlog -sn | head -3
266 michael_soldatkin
245 Aleksandr
153 Alexandr Gubanov

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

Конвертировать файл из подготовленного в неподготовленный

A
git rm --cached filename
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Отследить историю файла

A

git log --follow filename

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

Добавить неотслеживаемый локальный файл

A
.git/info/exclude
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Игнорируем все .о файлы, но отследим один файл в подкаталоге

A
cat .gitignore
  *.o
	cd ./cache
	cat .gitignore
	!driver.o
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Pickaxe: Показывает комиты, в которых добавляется или удаляется заданная строка с сокращенным сообщением и размером хэша в указанном файле.

A
git log -Sinclude --pretty=oneline --abbrev-commit init/version.c
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Сделать ветку, указав начальную фиксацию

A
git branch my_branch dev_hot_fix
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Переключиться на другую ветку и очистить рабочий каталог

A
git switch other-branch --discard-changes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Сделать новую фиксацию, находясь в Detached Head

A
git checkout -b new_branch
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Удалить ветку

A

Force delete:

git branch -d bug/pr3
Force delete:
git branch -D bug/pr3
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Отмена слияния (восстановление рабочего каталога в состояние до слияния)

A
git reset --hard HEAD
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Отменить слияние после успешного завершения слияния локально.

A
git reset --hard ORIG_HEAD
17
Q

Вернуться к исходному состоянию конфликта слияния

A
git checkout -m
18
Q

Отменить последнюю фиксацию

A
git reset HEAD^
19
Q

Подробный пример отмены фиксации

A
git show-branch --more=5
[master] Add more foo.
[master^] Add master_file.
git reset HEAD^
git show-branch --more=5
[master] Add master_file.
20
Q

Отмена (инверсия) последней фиксации

A
git revert HEAD
21
Q

Revert the changes specified by the fourth last commit in HEAD

A
git revert HEAD~3
22
Q

Revert the changes done by commits from the fifth last commit in master (included) to the third last commit in master (included)

A
git revert master~5..master~2
23
Q

Apply and remove stash from the list

A
git stash pop
24
Q

Name a stash

A
git stash push -m 'description'

deprecated:
~~~
git stash save ‘description’
~~~

25
Q

Stash list

A
git stash list
26
Q

View a summary of a stash

A
$ git stash show
 index.html | 1 +
 style.css | 3 +++
 2 files changed, 4 insertions(+)
27
Q

View the full diff of a stash compared to the working directory

A
$ git stash show -p
diff --git a/style.css b/style.css
new file mode 100644
index 0000000..d92368b
--- /dev/null
\+++ b/style.css
@@ -0,0 +1,3 @@
28
Q

Delete a stash

A
$ git stash drop stash@{1}
Dropped stash@{1} (17e2697fd8251df6163117cb3d58c1f62a5e7cdb)
29
Q

Clear stash

A
git stash clear
30
Q

Stash untracked files

A
git stash --include-untracked
31
Q

To save a stash with a message

A

git stash push -m "my_stash_name"

32
Q

To save the specific file to stash with a message

A

git stash push -m "my_stash_name" example.txt

33
Q

To pop (i.e. apply and drop) the nth stash

A

git stash pop stash@{n}

34
Q

Undo not pushed last commit and save local changes

A

git reset --soft HEAD~1

35
Q

Show useful visual condensed git log with decorations (god)

A

git log --graph --oneline --decorate

36
Q

What is merge fast forward?

A

When the feature branch is ahead of the main, merge commit would not be created. to prevent this behavior use --no-ff