-
Notifications
You must be signed in to change notification settings - Fork 0
/
git_cheatsheet.txt
78 lines (57 loc) · 1.97 KB
/
git_cheatsheet.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
## branch
LIST
# show local branches
$ git branch
# show remote branches
$ git branch -r
# show all (fetched) branches
$ git branch -a
CLONE
# to clone a specific git branch
$ git clone -b <branch-name> https://github.com/username/repository.git
FETCH
# fetch specific remote branch; $ git branch -r, origin/main, eg. origin=remote_name, main=branch_name
$ git fetch <remote_name> <branch_name>
CREATE
# create local branch
git branch <new-branch-name>
# create and switch to the new branch
$ git checkout -b <new-branch-name>
# create local branch from remote one
$ git checkout -b <new_branch_name> <remote_name>/<remote_branch_name>
# create branch based on a specific revision hash, vytvorni novou vetev ze specifickeho komitu:
$ git checkout -b <new-branch-name> <commit-hash>
# ... create remote branch, see https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches
$ git push -u origin <branch-name>
$ git push --set-upstream origin <branch-name>
MERGE
$ git checkout <new-branch>
# ...develop some code...
$ git add .
$ git commit –m "Some commit message"
$ git checkout <main>
# Switched to branch 'main'
$ git merge <feature-branch>
SQUASH (vice komitu sjednoti do jednoho)
# za pouziti merge
$ git merge --squash feature/login
# za pouziti rebase (a chci sjednotit posledni 3 komity na HEAD-u)
$ git switch feature/login
$ git rebase -i HEAD~3
SWITCH
git switch <existing_branch> # prepne do existujici vetve
git switch -c <non_existing_branch> # vytvorni novou vetev a prepne do ni
RENAME
# move into branch which we want to rename
git checkout <branch-name-for-rename>
git branch -m <new-branch-name>
DELETE
git branch -d <existing-branch-name> # smaze branch (localni)
git push -d <remote-name> <existing-branch-name> # smaze branch (remote)
PROVERIT
# Create a new branch from the previous commit's hash
git branch develop 04c900cgit
--
MERGE CONFLICT
# process merge from branch (see MERGE) and create conflicts,
git mergetool