-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstarting.html
102 lines (75 loc) · 5.2 KB
/
starting.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
<!DOCTYPE html>
<html lang="en">
<!--
Website: Intro to Git
Page: starting.html
Author: Kevin Robell
Purpose: This page teaches the user how to make a git repository, add files, and make commits.
-->
<head>
<meta charset="utf-8" />
<title> Intro to Git </title>
<link href="css/sta.css" rel="stylesheet" type="text/css" />
<link href="css/styles.css" rel="stylesheet" type="text/css" />
</head>
<body class="body">
<header class="header">
<h1 class="title-txt"> What is </h1>
<img id="logo" src="img/Git-Logo-Black.png" alt="git logo" />
<h1 class="title-txt"> ? </h1>
</header>
<nav class="nav">
<a href="index.html">Home</a>
<a id="current-page" href="starting.html">Starting Out</a>
<a href="branching.html">Branching</a>
<a href="remote-server.html">Remote Server</a>
</nav>
<div class="box w4">
<h2 class="center"> Starting Out </h2>
<hr>
This page teaches you how to make a git repository, add files, and make commits.
</div>
<div class="box w3">
First, you need to check if git is installed. Type <code>git —version</code> to find out the local version. Otherwise you will need to <a href="https://github.com/git-guides/install-git">install git</a>.
</div>
<img src="img/starting_page-console-1.png" alt="Console window showing how to check the git version using the git --version command." />
<div class="box w3">
Create the folder that will hold your project and enter it. Now you need to initialize your repository. Type <code>git init</code> in the command line. This will place a new git repo in the current directory.
</div>
<img src="img/starting_page-console-2.png" alt="Console window showing how to initialize a git repository using the git init command." />
<div class="box w3">
Next, I will show you how files are added to the repo. Git allows you to decide which files in the folder get tracked and which are ignored. Create a new empty text file called mammals.txt. We will now check the status of files in the repo by typing <code>git status</code>. It is good practice to check the status before adding files.
</div>
<img src="img/starting_page-console-3.png" alt="Console window showing how to check the status using the git status command." />
<div class="box w3">
You can see that the new file is untracked. That means we should add it to be tracked by typing <code>git add <filename></code>. Check the status again by typing <code>git status</code>.
</div>
<img src="img/starting_page-console-4.png" alt="Console window showing how to add a file to the commit using the git add filename command." />
<div class="box w3">
Now that we have added the file we can make a commit. A commit is a snapshot of all tracked files in the repo. Users are then allowed to see the state of tracked files over time. Type <code>git commit</code> and the default text editor will open up for you to type your commit message.
</div>
<img src="img/starting_page-console-6.png" alt="Console window showing how to make a commit using the git commit command." /><br>
<img src="img/starting_page-console-5.png" alt="Console window showing how to make the commit message using your default console text editor." />
<div class="box w3">
You’ve made your first commit. Now let’s practice and make another one. This time create two more files called two.txt and three.txt. Type <code>git add .</code> to add all untracked files. This time we will commit the files by typing <code>git commit -m “commit message”</code> which avoids the use of the external text editor.
</div>
<img src="img/starting_page-console-7.png" alt="Console window showing how to add all untracked files using the git add . command and commit using the git commit -m 'commit message' command." />
<div class="box w3">
You can remove files by deleting them and making another commit. Let’s delete two.txt and three.txt.
</div>
<img src="img/starting_page-console-8.png" alt="Console window showing how to delete tracked files from your project." />
<div class="box w3">
To look at the commits we’ve made so far type <code>git log</code>.
</div>
<img src="img/starting_page-console-9.png" alt="Console window showing how to access the log data using the git log command." />
<div class="box w4">
Now you know how to initialize a repo and make commits. The next step is branching.
</div>
<a class="btn lines" href="branching.html">Continue learning →</a>
<footer class="footer">
CST336 Internet Programming. 2020© Robell<br>
<a href="https://git-scm.com/downloads/logos" target="_blank">Git Logo</a> by <a href="https://twitter.com/jasonlong" target="_blank">Jason Long</a>.
Built using <a href="https://apainintheneck.github.io/sta.css/" target="_blank">sta.css</a>.
</footer>
</body>
</html>