-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.txt
125 lines (89 loc) · 2.57 KB
/
git.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
1. Create a Repository from GitHub Website
2. git clone https://repository-url.git
3. git status
(Shows untracked files in working directory)
git add file
(Put file in staging area)
4. git commit -m "Commit message"
Local Repository:-
Working --> Staging --> Repository
Directory Area (.git folder)
|
|
v
Remote Repository:-
5. git push origin master (Push to remote repository)
---------------------------------------------------------
Git Branching:-
list all ->
git branch -a
create branch ->
git branch <branch-name>
git checkout -b <branch-name>
delete locally branch ->
git branch -d <branch-name>
delete remote branch ->
git branch origin --delete <branch-name> OR git branch origin: <branch-name>
# Fetch changes from all remotes and locally delete
# remote deleted branches/tags etc
# --prune will do the job :-;
git fetch --all --prune
git fetch -p
switch to branch ->
git checkout <branch-name>
---------------------------------------------------
Git Tags:
git tag
git tag <tag-name(stable)/> <branch-name(master)/>
git tag <tag-name(unstable)/> <branch-name(develop)/>
git tag -a <tag-name(v0.1-alpha)/> -m "Release 0.1 (Alpha)" <id-hash>
git show <tag-name(v0.1-alpha)/>
git push origin <tag-name(stable)/>
git push --tags
git tag -d <tag-name(v0.2-alpha)/>
git push origin :<tag-name(v0.2-alpha)/>
------------------------------------------------------
Git Logs:
git log --oneline
git log --oneline --graph
git log --oneline --decorate
git log --stat
git reflog
------------------------------------------------------
GitHub Issues:
Labels, Milestones, and Issues.
Pull requests are a type of issue
Issues have #<number>
Example: #2 or #54
To close an issue simply type close #<number> in commit message
Example: git commit -m "..., close #<number>"
git push
---------------------------------------------------
##Git Flow:
-----------
###Feature:
git flow feature start <feature-name>
list ->
git flow feature
publish to remote ->
git flow feature publish <feature-name>
git push origin feature/<feature-name>
git flow feature finish <feature-name>
-----------------------------------------------------
Git Reset:
commited in master mistakenly
ok go to required branch by checkout and then
use git cherry-pick <commit-hash>
then go back to master branch
and reset -> soft, mixed, hard
git reset --soft <commit-hash>
-> have our files in staging area
git reset <commit-hash>
-> have our files in working directory(untracked)
git reset --hard <commit-hash>
git clean -df (directory, files)
Backup
git reflog
git checkout <commit-hash>
git log
git branch backup