-
Notifications
You must be signed in to change notification settings - Fork 0
/
git commands.txt
129 lines (80 loc) · 3.46 KB
/
git commands.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
126
127
128
129
1.git status
==========
to check the status and all use this command .It will show the all changed files and directories
like
a.modified files = changes are happen in the existing files
b.untraced files= new file
2.git add .
=========
this command is used for the to move the changed and untraced files into staging area
if you want to move specific file into the staging area use the below command
git add filename
================
3.git commit -m "message you want to give here"
=============================================
this command is moved the staging files into the local repository
4.git push origin branchName
==========================
this command is used to push all the local repository[your branch] files into the central repository[your branch]
you don't need to create a branch in the central repo automatically it will create after you push
5.git branch
==========
to check the number of branches in your local repository
6.git branch -a
=============
to check the branches in the remote repository
7.git checkout existing-branchName
================================
to switch the one branch to another branch
8.git checkout -b new-branchName
==============================
it will be create new branch and also switch branch at a single hit
9.git push origin branchName
==========================
to push the changes files into the central repository at the first times
and After second time on word use
git push
========
10.git merge sourcebrancename
==========================
to merge the one source branch into the destiny branch
11.git rebase sourcebrancename
===========================
this command is also same as the merge but the difference is if we use the merge command
the CID will be create instead of use the rebase The CID will not create
12.git stash save "label Name"
===========================
to save the temporary files and all and you can revert those stash files by using the POP
when you save the temporary files in the stash memory it will store in the index format 0-1-2-3 like
stash@{0}
stash@{1}
it will store like this
when ever you want to revert those temporary files into your workspace use the command
1. git stash pop ----> first stash memory will be revert
2. git stash pop stash@{0} -----> 0 index's stash memory will be revert
13.git log
=======
it will show the commit id and all .its very useful to troubleshooting the error and all
a.git log --oneline
=================
it used to print all the CID's at single line only
b.git log -n
==========
it used to print the number of CID's by replacing the n into numbers [n=1 or 2 or etc..,]
c.git log --author=nameofAuthor
=============================
get the CID's based on the author name
d.git log --grep "commit Message"
===============================
based on the commit message the CID's will print
e.git log --file filename
=======================
based on the filename you give the CID's will print
14.git pull --rebase
=================
update the local branch[any branch main or subbranch] up to date with central repository
15.git cherry-pic CID
==================
git cherry-pick <CID1> <CID2> <CID3>
====================================
if you want merge particular commit use the above command