-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit.html
240 lines (210 loc) · 14.7 KB
/
git.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<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>Git Tutorial</title>
<link rel="stylesheet" href="gitStyle.css">
</head>
<body>
<div class="main">
<h2 class="name">Name : Amna Azam</h2>
<h2 class="rollno">Roll no : BSEF19M009</h2>
<hr><br>
<img src="images/git-intro.png" alt="introduction" class="intro-image">
<h3 class="tutorial">What is git? </h3>
<p class="para">         Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Git tracks the changes you make to files, so you have a record of what has been done, and you can revert to specific versions should you ever need to.
Git also makes collaboration easier, allowing changes by multiple people to all be merged into one source.Git is software that runs locally. Your files and their history are stored on your computer
. You can also use online hosts (such as GitHub) to store a copy of the files and their revision history.
Having a centrally located place where you can upload your changes and download changes from others, enable you to collaborate more easily with other developers.
</p><br><br>
<img src="images/gitLifecycle.png" alt="lifecycle" class="lifecycle"><br><br>
<h3 class="tutorial">Which git-commands we will see in this tutorial? </h3>
<img src="https://assets-global.website-files.com/5d514fd9493b0575f03520bd/5d664e055e626f58c6282c5a_10-git-commands-1648x824.jpg" alt="" class="cmds">
<p>The commands are given below:</p>
<ul class="myList">
<li><a href="#init" title="See git init command">git init</a></li>
<li><a href="#status" title="See git status command">git status</a></li>
<li><a href="#add" title="See git add command">git add</a></li>
<li><a href="#push" title="See git push command">git push</a></li>
<li><a href="#fetch" title="See git fetch command">git fetch</a></li>
<li><a href="clone" title="See git clone command">git clone</a></li>
<li><a href="#branch" title="See git branch command">git branch</a></li>
<li><a href="#newBranch" title="See git branch newBranch command">git branch myNewBranch</a></li>
<li><a href="#checkout" title="See git checkout command">git checkout myNewBranch</a></li>
<li><a href="#merge" title="See git merge command">git merge</a></li>
<li><a href="#clean" title="See git clean command">git clean</a></li>
<li><a href="#commit" title="See git commit command">git commit -m ["msg"]</a></li>
<li><a href="#config" title="See git config command">git config</a></li>
<li><a href="#log" title="See git log command">git log</a></li>
<li><a href="#diff" title="See git diff command">git diff</a></li>
<li><a href="#diffStage" title="See git diff --staged command">git diff --staged</a></li>
<li><a href="#pull" title="See git pull command">git pull</a></li>
<li><a href="#reset" title="See git reset command">git reset</a></li>
<li><a href="#remote" title="See git remote command">git remote add [alias] [url]</a></li>
</ul>
<br><br>
<p class="ins">Before proceeding, You must open command prompt in your directory and enter following commands: </p><br>
<h2 class="initHeading" id="init">1 - git init</h2>
<p>The git init command creates a new Git repository. To initialize a repository,
Git creates a hidden directory called . git . That directory stores all of the objects and refs that
Git uses and creates as a part of your project's history.
This folder is hidden to protect you from accidentally deleting its contents.</p><br>
<p> - To write this command, you will write git init and will press Enter.</p><br>
<img src="images/git-init.png" alt="" class="initimg">
<br><br><br>
<h2 class="initHeading" id="status">2 - git status</h2>
<p>The git status command displays the state of the working directory and
the staging area. It lets you see which changes have been staged, which haven't, and
which files aren't being tracked by Git.
Status output does not show you any information regarding the committed project history.</p><br>
<p> - To write this command, you will write git status and will press Enter.</p><br>
<p>There may be different scenerios ehen you press git status command.</p>
<p>
~ If you have untracked files: </p>
<img src="images/untrack.jpg" alt="" class="initimg">
<br><br><br>
<p> ~ If you have any modified files: </p>
<img src="images/modified.jpg" alt="" class="initimg">
<br><br>
<p> ~ If you have all things updated: </p>
<img src="images/update.jpg" alt="" class="initimg">
<br><br><br>
<h2 class="initHeading" id="add">3 - git add</h2>
<p>The git add command adds a change in the working directory to the staging area.
It tells Git that you want to include updates to a particular file in the next commit.
However, git add doesn't really affect the repository in any significant way
—changes are not actually recorded until you run git commit </p><br>
<p> - To write this command, you will write git add yourFileName and will press Enter.</p><br>
<img src="images/git-add.png" alt="" class="initimg">
<br><br>
<p>If you want to add all files in stag area (not one by one), here you go : </p>
<img src="images/git-add-all.png" alt="add all image" class="initimg">
<br><br><br>
<h2 class="initHeading" id="push">4 - git push</h2>
<p>The git push command is used to upload local repository content to a remote repository.
Pushing is how you transfer commits from your local repository to a remote repo. Before pushing the content, you must all commit before
and there should not be changes from your remote repository. You will have to pull them before.</p><br>
<p> - To write this push command, you will write following commands and will press Enter.</p>
<p> ~ If you are pushing your data first time, you have to use following 3 commands in which you will give the address
of your remote repository to these commands and will atell about branch as well.
</p>
<img src="images/git-push.jpg" alt="" class="initimg">
<br><br>
<p> ~ Later on, you will use on git push command.</p>
<img src="images/git-push-sec.jpg" alt="" class="initimg">
<br><br><br>
<h2 class="initHeading" id="fetch">5 - git fetch</h2>
<p>The git fetch command is used to download the contents from a remote repository into local repository.
It is the command that tells your local git to retrieve the latest meta-data info from the original (yet doesn't do any file transferring.
It's more like just checking to see if there are any changes available). It is the safer version of git pull.
</p><br>
<p> - To write this command, you will write git fetch and will press Enter.</p>
<img src="images/git-fetch.png" alt="" class="initimg">
<br><br><br>
<h2 class="initHeading" id="clone">6 - git clone [url]</h2>
<p>The "clone" command downloads or make a copy of an existing Git repository to your local computer.
In this command, you specifies the URL of the remote repository which you want to clone and
the name of the folder on your local machine where the repository will be downloaded into but it is optional.
If you do not mention folder name, it will create folder named as your repository and clone repository there.
</p><br>
<p> - To write this command, you will write git clone yourRepositoryLink and will press Enter.</p>
<img src="images/git-clone.png" alt="" class="initimg">
<br><br>
<p>Since I did not mention any folder explicitly, it created folder named from my repository and start cloning there. </p>
<img src="images/git-clone-folder.png" alt="" class="initimg">
<br><br><br>
<h2 class="initHeading" id="branch">7 - git branch</h2>
<p>This command just displays the names of all the branches in the working repository.
</p><br>
<p> - To write this command, you will write git branch and will press Enter.</p>
<p>Here is only one branch in this case i.e. main.</p>
<img src="images/git-branch.png" alt="" class="initimg">
<br><br><br>
<h2 class="initHeading" id="newBranch">8 - git branch myNewBranch</h2>
<p>This command is used to create new branch.
Creating a new branch allows you to isolate your changes from the master branch.
If your experimentation goes well you always have the option to merge your changes into the master branch.
If things don't go so well you can always discard the branch or keep it within your local repository.
</p><br>
<p> - To create new branch, you will write git branch new_branch and will press Enter.</p>
<p>This will create new branch.</p>
<p>P.S. git branch command shows all the available branches in repository.</p>
<img src="images/git-branch-newbranch.png" alt="" class="initimg">
<br><br>
<p>If you create a branch and immediately want to switch to that branch you write this command "git checkout -b myNewBranch"</p>
<p>This will create new branch and will shift to that branch as well.</p>
<img src="images/git-create-switch.png" alt="create-switch">
<br><br><br>
<h2 class="initHeading" id="checkout">9 - git checkout myNewBranch</h2>
<p>This command is used to switch the branch which branch name you mention.
Here <span style="color:red">*</span> sign represent the current branch name.
</p><br>
<p> - To switch to other branch, you will write git branch new_branch and will press Enter.</p>
<p>This will switch to new_branch.</p>
<p>P.S. git branch command shows all the available branches in repository and <span style="color:red">*</span> sign represents cureent branch.</p>
<img src="images/swtiching-branch.png" alt="" class="initimg">
<br><br><br>
<h2 class="initHeading" id="merge">10 - git merge myTempBranch</h2>
<p>To merge branches locally, use git checkout to switch to the branch you want to merge into.
This branch is typically the main branch.
Next, use git merge and specify the name of the other branch to bring into this branch.</p><br>
<p> - To merge the branches, you must be in your main branch and will write git merge new_branch and will press Enter.</p>
<p>This will merge new branch to your main branch.</p>
<img src="images/swtiching-branch.png" alt="" class="initimg">
<br><br><br>
<h2 class="initHeading" id="clean">11 - git clean </h2>
<p>It removes all untracked files from local repository.</p>
<br><br><br>
<h2 class="initHeading" id="commit">12 - git Commit -m ["msg"] </h2>
<p>The "commit" command is used to save your changes to the local repository.
Note that you have to explicitly tell Git which changes you want to include in a commit before running the "git commit" command.
This means that a file won't be automatically included in the next commit just because it was changed.</p>
<br>
<img src="images/git-commit.png" alt="">
<br><br><br>
<h2 class="initHeading" id="config">13 - git config </h2>
<p>This command lists all the available options in quite a bit of detail.</p>
<br>
<img src="images/git-config.png" alt="">
<br><br><br>
<h2 class="initHeading" id="log">14 - git log </h2>
<p>This command displays all the commits you have written in you repository.</p>
<br>
<img src="images/git-log.png" alt="">
<br><br><br>
<h2 class="initHeading" id="diff">15 - git diff </h2>
<p>This command compares the working tree with staging area. It is the diff of what is changed but not staged.
</p>
<br>
<img src="images/git-diff.png" alt="">
<br><br><br>
<h2 class="initHeading" id="diffStage">16 - git diff --staged</h2>
<p>This commands shows difference of what is staged but not yet commited.
</p>
<br>
<img src="images/git-diff-staged.png" alt="">
<br><br><br>
<h2 class="initHeading" id="pull">17 - git pull </h2>
<p>The git pull command is actually a combination of two other commands, git fetch followed by git merge .
The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content.
Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows.
</p>
<br>
<img src="images/git-pull.png" alt="">
<br><br><br>
<h2 class="initHeading" id="reset">18 - git reset </h2>
<p>This command unstage a file while retaining the changes in working directory.</p>
<p>Here firstly files were in staged area but after this git reset command, all the files go in untracked area.</p>
<br>
<img src="images/git-reset.png" alt="">
<br><br><br>
<h2 class="initHeading" id="remote">19 - git remote add [alias] [url] </h2>
<p>Instead of referencing the repositories by their full URLs, you give alias to your remote repository.</p>
<p>git remote command displays that alias.</p>
<br>
<img src="images/git-remote.png" alt="">
</div>
</body>
</html>