-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblog-one.html
183 lines (180 loc) · 6.65 KB
/
blog-one.html
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Most used git commands</title>
<link href="style.css" rel="stylesheet" />
</head>
<body>
<nav class="navigation">
<div class="nav-brand">DEVRAJ ROY</div>
<ul class="unordered nav-pills">
<li class="list-item-inline">
<a class="header-link" href="/">Home</a>
</li>
<li class="list-item-inline">
<a class="header-link" href="projects.html">Projects</a>
</li>
<li class="list-item-inline">
<a class="header-link link-active" href="blogs.html">Blogs</a>
</li>
</ul>
</nav>
<div class="blog-body">
<h1 class="blog-header">Most used git commands</h1>
<p class="blog-header-date">28 Sep,2021</p>
<img src="images/github-social.png" alt="" class="blog-header-img" />
<p class="blog-para">
So, as a dev every one of us be it a beginner or a working professional,
has used git or know about it. We all know what its purpose is, if not
let me give you a small introduction of what git exactly is.
</p>
<img src="images/github-octocat.png" alt="" class="blog-header-img" />
<p class="blog-para">
But first let me tell you one important difference, as most of the
beginners seem to confuse between git and github, as I myself did.
</p>
<img src="images/git-github.jpg" alt="" class="blog-header-img" />
<p class="blog-para">
So, the difference is that git is a version control and github is a
software hosting website. Yes, both works together but has a different
features and agenda. So, keeping that in mind lets move forward.
</p>
<img src="images/forward.jpg" alt="" class="blog-header-img" />
<p></p>
<p class="blog-para blog-para-normal">
<span>
<b class="blog-heading"> Git: </b>
</span>
<br />
<br />
Git is a version control as I mentioned earlier, what it means is that
git helps us keep track of the changes we make in our project and make a
checkpoint for every changes we save using git commit, so that we can
roll back our project to any checkpoint if there is any issue. Which is
quite powerful and useful. So, that's the reason why I would like to
share some of the most used git commands in every day work, which I use
everyday.
</p>
<p class="blog-para blog-para-normal">
<span>
<b class="blog-heading">So, here is the list: </b>
</span>
<br />
<br />
<b>1. git init</b>
<br />
<br />
This is use to initialize an empty git repository in your new or
existing project. This is the first command to be used before you can do
anything else with git.
<pre>
<code>
c:\my project\git init
</code>
</pre>
</p>
<p class="blog-para blog-para-normal">
<b>2. git status</b>
<br />
<br />
This is use to check the status of the project saved in git repository.
eg: It will show you which branch you are currently on, the changes you made recently,
which changes you have staged for commit etc.
<pre>
<code>
c:\my project\git status
</code>
</pre>
</p>
<p class="blog-para blog-para-normal">
<b>3. git add</b>
<br />
<br />
It stages or adds all the recent changes to be committed.
Which is saving a checkpoint for your recent changes.
<pre>
<code>
//This "." after add is for adding all the changes together.
c:\my project\git add .
</code>
</pre>
</p>
<p class="blog-para blog-para-normal">
<b>4. git commit</b>
<br />
<br />
It is used to create a checkpoint of your changes so to be able to track your changes and revert your project to any checkpoint if needed so. You need to add a commit message along with it for identification, which is very useful.
<pre>
<code>
c:\my project\git commit -m "message for your commit"
</code>
</pre>
</p>
<p class="blog-para blog-para-normal">
<b>5. git push</b>
<br />
<br />
It is used to push all your tracked and saved changes of your project you made using commit to a remote repository which would be github. Then you can check your project in github and see all the changes you made.
<pre>
<code>
//git push "remote_URL/remote_name" "branch"
c:\my project\git push origin master
</code>
</pre>
</p>
<p class="blog-para blog-para-normal">
<b>6. git pull</b>
<br />
<br />
It is used to pull or get all the changes from a remote repository to your local repository so that you are update with the changes in remote repo or your repositories are in sync.
<pre>
<code>
c:\my project\git pull
</code>
</pre>
</p>
<p class="blog-para blog-para-normal" >
<b>7. git remote</b>
<br />
<br />
It is used to link or connect local repository with remote repository using the command add,
only after linking remote repo you can push your changes to github and save it there for further usage.
You can also check if there is any repository linked to your project by using the command "git remote -v".
If there is no repo linked then it will return blank else the url will be displayed.
<pre>
<code>
//To check remote url links
c:\my project\git remote -v
//To add remote url
git remote add origin https://github.com/devraj-alt/my-project.git
</code>
</pre>
</p>
</div>
<footer class="footer">
<div class="footer-header">Social Media Presence</div>
<ul class="social-link non-bullet">
<li class="list-item-inline">
<a class="header-link" href="https://github.com/devraj-alt"
>Git Hub</a
>
</li>
<li class="list-item-inline">
<a class="header-link" href="https://twitter.com/DevrajR23329877?s=20"
>Twitter</a
>
</li>
<li class="list-item-inline">
<a
class="header-link"
href="https://www.linkedin.com/in/devraj-roy-2036a5221"
>LinkedIn</a
>
</li>
</ul>
</footer>
</body>
</html>