|
67 | 67 | <li class="toctree-l1 current"><a class="reference internal current" >Git</a>
|
68 | 68 | <ul class="current">
|
69 | 69 | <li class="toctree-l2 current"><a class="reference internal current" href="#">Git Basics</a>
|
| 70 | + <ul class="current"> |
| 71 | + <li class="toctree-l3"><a class="reference internal" href="#introduction">Introduction</a> |
| 72 | + <ul> |
| 73 | + <li class="toctree-l4"><a class="reference internal" href="#objectives">Objectives</a> |
| 74 | + </li> |
| 75 | + </ul> |
| 76 | + </li> |
| 77 | + <li class="toctree-l3"><a class="reference internal" href="#section-1-configuring-git">Section 1: Configuring Git</a> |
| 78 | + <ul> |
| 79 | + <li class="toctree-l4"><a class="reference internal" href="#setting-up-user-information">Setting Up User Information</a> |
| 80 | + </li> |
| 81 | + </ul> |
| 82 | + </li> |
| 83 | + </ul> |
70 | 84 | </li>
|
71 | 85 | <li class="toctree-l2"><a class="reference internal" href="../git-and-github/">Git And Github</a>
|
72 | 86 | </li>
|
|
102 | 116 | <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
103 | 117 | <div class="section" itemprop="articleBody">
|
104 | 118 |
|
105 |
| - <p>Setting up Git</p> |
106 |
| -<p>Introduction</p> |
| 119 | + <h1 id="setting-up-git">Setting up Git</h1> |
| 120 | +<h2 id="introduction">Introduction</h2> |
107 | 121 | <p>This guide will walk you through the steps to properly set up Git on your machine. You will configure Git, generate SSH keys for secure authentication, set up your user identity, and, if necessary, configure a proxy for Git operations.</p>
|
108 |
| -<p>Objectives</p> |
109 |
| -<p>By the end of this guide, you will:</p> |
110 |
| -<pre><code>• Configure Git using the terminal. |
111 |
| -• Generate SSH keys for secure communication. |
112 |
| -• Set and manage your Git user identity. |
113 |
| -• Configure a proxy for Git operations (if required). |
114 |
| -</code></pre> |
115 |
| -<p>Section 1: Configuring Git</p> |
116 |
| -<p>Setting Up User Information</p> |
| 122 | +<h3 id="objectives">Objectives</h3> |
| 123 | +<p>By the end of this guide, you will be able to:</p> |
| 124 | +<ul> |
| 125 | +<li>Configure Git using the terminal.</li> |
| 126 | +<li>Generate SSH keys for secure communication.</li> |
| 127 | +<li>Set and manage your Git user identity.</li> |
| 128 | +<li>Configure a proxy for Git operations (if required).</li> |
| 129 | +</ul> |
| 130 | +<hr /> |
| 131 | +<h2 id="section-1-configuring-git">Section 1: Configuring Git</h2> |
| 132 | +<h3 id="setting-up-user-information">Setting Up User Information</h3> |
117 | 133 | <p>To personalize your Git environment, configure your username and email. This information will be attached to every commit you make.</p>
|
118 | 134 | <p>Use the following commands:</p>
|
119 |
| -<p>git config --global user.name "Your Name" |
| 135 | +<p>```bash |
| 136 | +git config --global user.name "Your Name" |
120 | 137 | git config --global user.email " [email protected]" </p>
|
121 | 138 | <p>Verifying Configuration</p>
|
122 |
| -<p>To check your current settings, use:</p> |
123 |
| -<p>git config --list</p> |
124 |
| -<p>Task: Set your username and email, then verify the configuration using the above command.</p> |
| 139 | +<p>To check your current settings, use: |
| 140 | +```bash |
| 141 | +git config --list</p> |
| 142 | +<p>Task: |
| 143 | +Set your username and email, then verify the configuration using the above command.</p> |
125 | 144 | <p>Section 2: Generating SSH Keys</p>
|
126 | 145 | <p>SSH keys provide secure access to Git services (like GitHub or GitLab), allowing you to interact with remote repositories without entering your password every time.</p>
|
127 | 146 | <p>Generating an SSH Key</p>
|
128 | 147 | <p>Run the following command in your terminal:</p>
|
129 |
| -<p>ssh-keygen -t rsa -b 4096</p> |
| 148 | +<p>```bash |
| 149 | +ssh-keygen -t rsa -b 4096</p> |
130 | 150 | <p>Follow the prompts and press Enter to accept the default file location.</p>
|
131 | 151 | <p>Adding SSH Key to GitHub/GitLab</p>
|
132 | 152 | <p>Once the key is generated:</p>
|
133 |
| -<pre><code>1. Copy the public key to your clipboard: |
134 |
| -</code></pre> |
135 |
| -<p>cat ~/.ssh/id_rsa.pub</p> |
136 |
| -<pre><code>2. Go to your GitHub or GitLab account settings. |
137 |
| -3. Navigate to SSH and GPG keys and paste the key. |
138 |
| -</code></pre> |
139 |
| -<p>Task: Generate an SSH key and add it to your GitHub or GitLab account.</p> |
| 153 | +<ul> |
| 154 | +<li>Copy the public key to your clipboard:</li> |
| 155 | +</ul> |
| 156 | +<p>```bash |
| 157 | +cat ~/.ssh/id_rsa.pub</p> |
| 158 | +<ul> |
| 159 | +<li>Go to your GitHub or GitLab account settings.</li> |
| 160 | +<li>Navigate to SSH and GPG keys and paste the key.</li> |
| 161 | +</ul> |
| 162 | +<p>Task: |
| 163 | +Generate an SSH key and add it to your GitHub or GitLab account.</p> |
140 | 164 | <p>Section 3: Proxy Configuration (Optional)</p>
|
141 | 165 | <p>If you’re working behind a corporate firewall or restricted network, you may need to configure Git to use a proxy.</p>
|
142 | 166 | <p>Setting Up a Proxy</p>
|
143 | 167 | <p>To set up a proxy, run:</p>
|
144 |
| -<p>git config --global http.proxy http://proxy.example.com:8080</p> |
| 168 | +<p>```bash |
| 169 | +git config --global http.proxy http://proxy.example.com:8080</p> |
145 | 170 | <p>Replace proxy.example.com:8080 with your actual proxy details.</p>
|
146 | 171 | <p>Verifying Proxy Configuration</p>
|
147 | 172 | <p>To confirm the proxy is set up correctly:</p>
|
148 |
| -<p>git config --global http.proxy</p> |
149 |
| -<p>Task: If needed, configure your proxy settings and verify them using the above commands.</p> |
| 173 | +<p>```bash |
| 174 | +git config --global http.proxy</p> |
| 175 | +<p>Task: |
| 176 | +If needed, configure your proxy settings and verify them using the above commands.</p> |
150 | 177 | <p>Practical Exercise</p>
|
151 | 178 | <p>Follow these steps to complete your setup:</p>
|
152 |
| -<pre><code>1. Configure Git with your username and email. |
153 |
| -2. Generate an SSH key and add it to your GitHub or GitLab account. |
154 |
| -3. If necessary, set up a proxy. |
| 179 | +<pre><code>- Configure Git with your username and email. |
| 180 | +- Generate an SSH key and add it to your GitHub or GitLab account. |
| 181 | +- If necessary, set up a proxy. |
155 | 182 | </code></pre>
|
156 | 183 | <p>Verify your configuration with:</p>
|
157 |
| -<p>git config --list</p> |
| 184 | +<p>```bash |
| 185 | +git config --list</p> |
158 | 186 | <p>Additional Resources</p>
|
159 |
| -<pre><code>• Official Git Documentation |
160 |
| -• GitHub SSH Key Setup Guide |
161 |
| -• Git Configuration Best Practices |
162 |
| -</code></pre> |
| 187 | +<ul> |
| 188 | +<li>Official Git Documentation</li> |
| 189 | +<li>GitHub SSH Key Setup Guide</li> |
| 190 | +<li>Git Configuration Best Practices</li> |
| 191 | +</ul> |
163 | 192 | <p>With these steps completed, Git is now properly configured on your machine, and you’re ready to start working with version control.</p>
|
| 193 | +<p>This format is designed for an MkDocs-based project, with clear sections and tasks. Let me know if you'd like to make any further adjustments!</p> |
164 | 194 |
|
165 | 195 | </div>
|
166 | 196 | </div><footer>
|
|
0 commit comments