<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sam Anderson</title>
    <description>The latest articles on DEV Community by Sam Anderson (@sam_anderson_5ceb59b3f4b1).</description>
    <link>https://dev.to/sam_anderson_5ceb59b3f4b1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3081987%2F39e378c0-5e40-46f0-921f-bda3affe768d.png</url>
      <title>DEV Community: Sam Anderson</title>
      <link>https://dev.to/sam_anderson_5ceb59b3f4b1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sam_anderson_5ceb59b3f4b1"/>
    <language>en</language>
    <item>
      <title>Mastering Advanced Git Commands</title>
      <dc:creator>Sam Anderson</dc:creator>
      <pubDate>Sat, 26 Apr 2025 03:40:44 +0000</pubDate>
      <link>https://dev.to/sam_anderson_5ceb59b3f4b1/mastering-advanced-git-commands-11k6</link>
      <guid>https://dev.to/sam_anderson_5ceb59b3f4b1/mastering-advanced-git-commands-11k6</guid>
      <description>&lt;p&gt;Git is a powerful tool, and knowing some advanced commands can really level up your version control game. In this post, we'll go through some commonly used Git commands along with their purpose, how to use them.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. git diff
&lt;/h2&gt;

&lt;p&gt;Purpose: Show differences between two commits or working directory and index.&lt;/p&gt;

&lt;p&gt;Command: git diff&lt;/p&gt;

&lt;h2&gt;
  
  
  2. git log
&lt;/h2&gt;

&lt;p&gt;Purpose: Show commit history.&lt;/p&gt;

&lt;p&gt;Command: git log&lt;/p&gt;

&lt;h2&gt;
  
  
  3. git clone
&lt;/h2&gt;

&lt;p&gt;Purpose: Clone a remote repository to your system.&lt;/p&gt;

&lt;p&gt;Command: git clone &lt;a href="https://github.com/samandersony2003/24MCR087" rel="noopener noreferrer"&gt;https://github.com/samandersony2003/24MCR087&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwfdv1w1ewwvbw5dpsfi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwfdv1w1ewwvbw5dpsfi.jpg" alt="Image description" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. git pull
&lt;/h2&gt;

&lt;p&gt;Purpose: Pull changes from remote to local repo.&lt;/p&gt;

&lt;p&gt;Command: git pull origin main&lt;/p&gt;

&lt;h2&gt;
  
  
  5. git push
&lt;/h2&gt;

&lt;p&gt;Purpose: Push local commits to remote.&lt;/p&gt;

&lt;p&gt;Command: git push origin main&lt;/p&gt;

&lt;h2&gt;
  
  
  6. git blame
&lt;/h2&gt;

&lt;p&gt;Purpose: Show who last modified each line of a file.&lt;/p&gt;

&lt;p&gt;Command: git blame ML.txt&lt;/p&gt;

&lt;h2&gt;
  
  
  7. git merge conflict (not a command)
&lt;/h2&gt;

&lt;p&gt;Note: Conflict occurs during a git merge.&lt;/p&gt;

&lt;p&gt;Here’s how to simulate:&lt;/p&gt;

&lt;p&gt;git checkout -b new-branch&lt;/p&gt;

&lt;p&gt;git checkout main&lt;/p&gt;

&lt;p&gt;git merge new-branch&lt;/p&gt;

&lt;h2&gt;
  
  
  8. git branch
&lt;/h2&gt;

&lt;p&gt;Purpose: List, create, or delete branches.&lt;/p&gt;

&lt;p&gt;Command: git branch&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2n2tk3lcn7ref800au0t.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2n2tk3lcn7ref800au0t.jpg" alt="Image description" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  9. git checkout -b
&lt;/h2&gt;

&lt;p&gt;Purpose: Create and switch to a new branch.&lt;/p&gt;

&lt;p&gt;Command: git checkout –b advanced-git-commands&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq7yq0umh2cyfpfxrobkh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq7yq0umh2cyfpfxrobkh.jpg" alt="Image description" width="800" height="425"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10 .gitignore
&lt;/h2&gt;

&lt;p&gt;Purpose: File to specify untracked files to ignore.&lt;/p&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;p&gt;Create .gitignore file in root directory.&lt;br&gt;
Add file patterns to ignore.&lt;/p&gt;

&lt;p&gt;e.g.:&lt;/p&gt;

&lt;p&gt;*.log&lt;br&gt;
node_modules/&lt;/p&gt;

&lt;p&gt;No command needed, Git automatically ignores the specified files.&lt;/p&gt;

&lt;p&gt;Github Repository:&lt;br&gt;
Github link: &lt;a href="https://github.com/samanderson2003/24MCR087" rel="noopener noreferrer"&gt;https://github.com/samanderson2003/24MCR087&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcq6ws7pxg1qia4n8y2tw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcq6ws7pxg1qia4n8y2tw.jpg" alt="Image description" width="800" height="385"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>ML day 1</title>
      <dc:creator>Sam Anderson</dc:creator>
      <pubDate>Thu, 24 Apr 2025 03:44:16 +0000</pubDate>
      <link>https://dev.to/sam_anderson_5ceb59b3f4b1/ml-day-1-1aoc</link>
      <guid>https://dev.to/sam_anderson_5ceb59b3f4b1/ml-day-1-1aoc</guid>
      <description>&lt;p&gt;&lt;strong&gt;Initialize a Git repository:&lt;/strong&gt;&lt;br&gt;
    git init&lt;br&gt;
Creates a new Git repository in the folder 24MCR087.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add a file to staging area:&lt;/strong&gt;&lt;br&gt;
    git add 24MCR087.txt&lt;br&gt;
Adds 24MCR087.txt to the staging area.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commit the file:&lt;/strong&gt;&lt;br&gt;
    git commit -m "Added Personal Details"&lt;br&gt;
Creates a commit with the message "Added Personal Details".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check Git status:&lt;/strong&gt;&lt;br&gt;
     git status&lt;br&gt;
Shows that 24MCR087.txt has been modified but not staged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;View commit log:&lt;/strong&gt;&lt;br&gt;
     git log&lt;br&gt;
Displays the commit history (one commit at this point).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add remote GitHub repository:&lt;/strong&gt;&lt;br&gt;
     git remote add origin &lt;a href="https://github.com/samanderson2003/24MCR087" rel="noopener noreferrer"&gt;https://github.com/samanderson2003/24MCR087&lt;/a&gt;&lt;br&gt;
Links the local repository to a remote GitHub repo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check current branch:&lt;/strong&gt;&lt;br&gt;
     git branch&lt;br&gt;
Shows the current branch is master.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rename branch from master to main:&lt;/strong&gt;&lt;br&gt;
     git branch -M main&lt;br&gt;
Renames the current branch to main.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Set Git global config for email and username:&lt;/strong&gt;&lt;br&gt;
    git config --global user.email "&lt;a href="mailto:sam.youngren2003@gmail.com"&gt;sam.youngren2003@gmail.com&lt;/a&gt;"&lt;br&gt;
git config --global user.name "Ajay978680"&lt;br&gt;
Sets your global Git identity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Push code to remote repo for the first time:&lt;/strong&gt;&lt;br&gt;
     git push -u origin main&lt;br&gt;
Pushes the main branch to GitHub and sets upstream tracking.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step-by-Step Git Commands Execution:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Initialize a Git repository:&lt;/strong&gt;&lt;br&gt;
    git init&lt;br&gt;
Creates a new Git repository in the folder 24MCR087.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add a file to staging area:&lt;/strong&gt;&lt;br&gt;
    git add 24MCR087.txt&lt;br&gt;
Adds 24MCR087.txt to the staging area.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Commit the file:&lt;/strong&gt;&lt;br&gt;
    git commit -m "Added Personal Details"&lt;br&gt;
Creates a commit with the message "Added Personal Details".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check Git status:&lt;/strong&gt;&lt;br&gt;
     git status&lt;br&gt;
Shows that 24MCR087.txt has been modified but not staged.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;View commit log:&lt;/strong&gt;&lt;br&gt;
     git log&lt;br&gt;
Displays the commit history (one commit at this point).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Add remote GitHub repository:&lt;/strong&gt;&lt;br&gt;
     git remote add origin &lt;a href="https://github.com/samanderson2003/24MCR087" rel="noopener noreferrer"&gt;https://github.com/samanderson2003/24MCR087&lt;/a&gt;&lt;br&gt;
Links the local repository to a remote GitHub repo.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check current branch:&lt;/strong&gt;&lt;br&gt;
     git branch&lt;br&gt;
Shows the current branch is master.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rename branch from master to main:&lt;/strong&gt;&lt;br&gt;
     git branch -M main&lt;br&gt;
Renames the current branch to main.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Set Git global config for email and username:&lt;/strong&gt;&lt;br&gt;
    git config --global user.email "&lt;a href="mailto:sam.youngren2003@gmail.com"&gt;sam.youngren2003@gmail.com&lt;/a&gt;"&lt;br&gt;
git config --global user.name "Ajay978680"&lt;br&gt;
Sets your global Git identity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Push code to remote repo for the first time:&lt;/strong&gt;&lt;br&gt;
     git push -u origin main&lt;br&gt;
Pushes the main branch to GitHub and sets upstream tracking.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F987qcdoi95hr6gth458j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F987qcdoi95hr6gth458j.png" alt="Image description" width="800" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmd29396z7fz47ngush73.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmd29396z7fz47ngush73.png" alt="Image description" width="800" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxirhpyz5dnewf6bj4smb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxirhpyz5dnewf6bj4smb.png" alt="Image description" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then , Again We will Modify or add new file means we need to follow the same steps, like&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add .
git commit -m “message”
git push origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
  </channel>
</rss>
