Apu Deb Chowdhury
Sylhet, Bangladesh
<p>I recently completed my undergraduate degree in computer science and engineering at Leading University(LU),Sylhet.</p>
<h2>Git Uses</h2>
<p>Git is a tool used for:</p>
<ul>
<li>Version control system</li>
<li>Keeping track of changes</li>
<li>Collaboration on projects</li>
</ul>
<p>Similar tools include:</p>
<ul>
<li>GitLab</li>
<li>Beanstalk</li>
<li>PerForce</li>
<li>Bitbucket</li>
</ul>
<p>More than 70% of developers use Git.</p>
<h2>Git & GitHub Difference</h2>
<ul>
<li>GitHub is a service; Git is a tool.</li>
<li>GitHub provides a GUI interface; Git provides a CLI (Command Line Interface).</li>
<li>GitHub is maintained on the web or cloud; Git is installed and maintained locally.</li>
</ul>
<h2>GitHub Version Check</h2>
<p>Check Git version:</p>
<pre><code>git --version</code></pre>
<h2>VS Code GitHub Account Configuration</h2>
<p>To check your username:</p>
<pre><code>git config user.name</code></pre>
<p>To check your email:</p>
<pre><code>git config user.email</code></pre>
<p>To configure your username:</p>
<pre><code>git config --global user.name "imdeb99"</code></pre>
<p>To configure your email:</p>
<pre><code>git config --global user.email "apudeb2000@gmail.com"</code></pre>
<h2>Git Project Push to GitHub</h2>
<ol>
<li><strong>Git Initialization:</strong>
<pre><code>git init</code></pre>
</li>
<li><strong>Git Add:</strong>
<pre><code>git add [file name] // to add a specific file
git add . // to add all files
Check file status (modified or not):
git statusRestore file status:
git restore [file name]Check differences:
git diffgit commit -m "first commit" // send a message like 'first commit'
-m refers to the messageCheck commit history:
git logCheck commit history with summary:
git log --onelineGet commit ID in log:
git log --onelineReset to a previous commit:
git reset --soft [commit id]Checkout a specific commit:
git checkout [commit id]Check remote origin:
git remote -vgit branch -M maingit push -u origin main <h2>Create a New Repository on the Command Line</h2>
<pre><code>echo "# git-tutorial" >> README.md
git init git add README.md git commit -m "first commit" git branch -M main git remote add origin https://github.com/imdeb99/git-tutorial.git git push -u origin main
<h2>Push an Existing Repository from the Command Line</h2>
<pre><code>git remote add origin https://github.com/imdeb99/git-tutorial.git
git branch -M main git push -u origin main