<?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: Moustafa</title>
    <description>The latest articles on DEV Community by Moustafa (@moustafaabedi).</description>
    <link>https://dev.to/moustafaabedi</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%2F2915588%2F2c9ac2c1-495c-416a-bdbe-906bab624d8e.jpg</url>
      <title>DEV Community: Moustafa</title>
      <link>https://dev.to/moustafaabedi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/moustafaabedi"/>
    <language>en</language>
    <item>
      <title>Git Documentation - Config, Reflog, and Tags</title>
      <dc:creator>Moustafa</dc:creator>
      <pubDate>Tue, 11 Mar 2025 19:48:47 +0000</pubDate>
      <link>https://dev.to/moustafaabedi/git-documentation-config-reflog-and-tags-38hm</link>
      <guid>https://dev.to/moustafaabedi/git-documentation-config-reflog-and-tags-38hm</guid>
      <description>&lt;h3&gt;
  
  
  1️⃣ Git Config
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;git config&lt;/code&gt; is used to configure Git settings at different levels: global, local, and system.&lt;/p&gt;

&lt;h4&gt;
  
  
  🔹 Setting User Information
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.name &lt;span class="s2"&gt;"Your Name"&lt;/span&gt;
git config &lt;span class="nt"&gt;--global&lt;/span&gt; user.email &lt;span class="s2"&gt;"your.email@example.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These commands set your username and email globally for all repositories.&lt;/p&gt;

&lt;h4&gt;
  
  
  🔹 Checking Current Configuration
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--list&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command displays all current configurations.&lt;/p&gt;

&lt;h4&gt;
  
  
  🔹 Setting Default Text Editor
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; core.editor &lt;span class="s2"&gt;"code --wait"&lt;/span&gt;  &lt;span class="c"&gt;# VS Code&lt;/span&gt;
git config &lt;span class="nt"&gt;--global&lt;/span&gt; core.editor &lt;span class="s2"&gt;"nano"&lt;/span&gt;         &lt;span class="c"&gt;# Nano Editor&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🔹 Removing Configurations
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git config &lt;span class="nt"&gt;--global&lt;/span&gt; &lt;span class="nt"&gt;--unset&lt;/span&gt; user.name
git config &lt;span class="nt"&gt;--global&lt;/span&gt; &lt;span class="nt"&gt;--unset&lt;/span&gt; user.email
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2️⃣ Git Reflog
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;git reflog&lt;/code&gt; is used to track the history of all references in a repository, even those that are not part of &lt;code&gt;git log&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  🔹 Viewing the Reflog History
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reflog
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command shows all actions related to HEAD, including commits, resets, and checkouts.&lt;/p&gt;

&lt;h4&gt;
  
  
  🔹 Recovering a Lost Commit
&lt;/h4&gt;

&lt;p&gt;If you accidentally reset or deleted a commit, use the commit hash from &lt;code&gt;git reflog&lt;/code&gt; to restore it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout &amp;lt;commit-hash&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🔹 Clearing the Reflog
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reflog expire &lt;span class="nt"&gt;--expire&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;now &lt;span class="nt"&gt;--all&lt;/span&gt;
git gc &lt;span class="nt"&gt;--prune&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;now
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This removes all reflog entries.&lt;/p&gt;




&lt;h3&gt;
  
  
  3️⃣ Git Tag
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;git tag&lt;/code&gt; is used to mark specific commits with a label, commonly for versioning.&lt;/p&gt;

&lt;h4&gt;
  
  
  🔹 Creating a Lightweight Tag
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git tag v1.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tags the latest commit as &lt;code&gt;v1.0.0&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  🔹 Creating an Annotated Tag (with message)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git tag &lt;span class="nt"&gt;-a&lt;/span&gt; v1.0.0 &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"Version 1.0.0 release"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🔹 Listing All Tags
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git tag
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🔹 Deleting a Tag
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git tag &lt;span class="nt"&gt;-d&lt;/span&gt; v1.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🔹 Pushing Tags to Remote Repository
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git push origin v1.0.0  &lt;span class="c"&gt;# Push a specific tag&lt;/span&gt;
git push origin &lt;span class="nt"&gt;--tags&lt;/span&gt;  &lt;span class="c"&gt;# Push all tags&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🔹 Checking Out a Tag
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout tags/v1.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  🔹 Creating a Branch from a Tag
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout &lt;span class="nt"&gt;-b&lt;/span&gt; new-branch v1.0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  📌 Summary
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git config --global user.name "Your Name"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Set global username&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git config --global user.email "your.email@example.com"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Set global email&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git config --list&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Show all configurations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git reflog&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Show reference logs (history of HEAD movements)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git reflog expire --expire=now --all&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Clear reflog history&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git tag v1.0.0&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create a lightweight tag&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git tag -a v1.0.0 -m "Version 1.0.0 release"&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create an annotated tag&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;git push origin --tags&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Push all tags to remote&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

</description>
    </item>
    <item>
      <title>Git Concepts - Second Day</title>
      <dc:creator>Moustafa</dc:creator>
      <pubDate>Tue, 11 Mar 2025 01:44:41 +0000</pubDate>
      <link>https://dev.to/moustafaabedi/git-concepts-4djm</link>
      <guid>https://dev.to/moustafaabedi/git-concepts-4djm</guid>
      <description>&lt;h2&gt;
  
  
  1- Undoing Commits (&lt;code&gt;reset&lt;/code&gt; vs. &lt;code&gt;revert&lt;/code&gt;)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;git reset&lt;/code&gt; - Undo commits and move the branch pointer
&lt;/h3&gt;

&lt;p&gt;Git &lt;strong&gt;reset&lt;/strong&gt; is used to undo commits. It comes in three types:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--soft&lt;/code&gt;&lt;/strong&gt; → Keeps changes in &lt;strong&gt;Staging (index)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--mixed&lt;/code&gt;&lt;/strong&gt; → Keeps changes in &lt;strong&gt;Working Directory&lt;/strong&gt; (default).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;--hard&lt;/code&gt;&lt;/strong&gt; → &lt;strong&gt;Deletes&lt;/strong&gt; commits and changes permanently.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git reset &lt;span class="nt"&gt;--soft&lt;/span&gt; HEAD~1  &lt;span class="c"&gt;# Undo last commit but keep changes staged&lt;/span&gt;
git reset &lt;span class="nt"&gt;--mixed&lt;/span&gt; HEAD~1  &lt;span class="c"&gt;# Undo last commit and unstage changes&lt;/span&gt;
git reset &lt;span class="nt"&gt;--hard&lt;/span&gt; HEAD~1  &lt;span class="c"&gt;# Undo commit and delete changes permanently! ⚠️&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;code&gt;git revert&lt;/code&gt; - Undo a commit &lt;strong&gt;without deleting history&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Unlike &lt;code&gt;reset&lt;/code&gt;, &lt;code&gt;revert&lt;/code&gt; &lt;strong&gt;creates a new commit&lt;/strong&gt; that cancels the changes of a previous commit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git revert HEAD  &lt;span class="c"&gt;# Reverts the last commit with a new commit&lt;/span&gt;
git revert &amp;lt;commit-hash&amp;gt;  &lt;span class="c"&gt;# Reverts a specific commit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use each?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Use &lt;code&gt;reset&lt;/code&gt;&lt;/strong&gt; when working &lt;strong&gt;locally&lt;/strong&gt; and want to completely remove a commit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use &lt;code&gt;revert&lt;/code&gt;&lt;/strong&gt; if the commit has already been pushed and you want to keep history clean.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2- Stashing - Saving Changes Temporarily
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git stash&lt;/code&gt; is used to &lt;strong&gt;save uncommitted changes temporarily&lt;/strong&gt; without committing them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git stash          &lt;span class="c"&gt;# Save changes and get a clean working directory  &lt;/span&gt;
git stash pop      &lt;span class="c"&gt;# Retrieve the latest stash and remove it  &lt;/span&gt;
git stash apply    &lt;span class="c"&gt;# Retrieve the latest stash without removing it  &lt;/span&gt;
git stash list     &lt;span class="c"&gt;# Show all saved stashes  &lt;/span&gt;
git stash clear    &lt;span class="c"&gt;# Delete all stashes  &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use &lt;code&gt;stash&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When working on a feature branch and need to switch to another branch &lt;strong&gt;without committing&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;When testing something quickly but don’t want to commit unfinished changes.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3- Rebasing - Merging Branches in a Linear Way
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git rebase&lt;/code&gt; &lt;strong&gt;moves commits from one branch to another&lt;/strong&gt; without creating extra merge commits.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git checkout feature-branch  
git rebase main  &lt;span class="c"&gt;# Moves feature-branch commits on top of main  &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When to use &lt;code&gt;rebase&lt;/code&gt;?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To keep commit history &lt;strong&gt;clean and linear&lt;/strong&gt; instead of multiple merge commits.&lt;/li&gt;
&lt;li&gt;To update a feature branch with the latest changes from &lt;code&gt;main&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  4- Interactive Rebasing - Editing Commit History
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;git rebase -i&lt;/code&gt; allows you to &lt;strong&gt;edit, reorder, squash, or delete commits&lt;/strong&gt; interactively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git rebase &lt;span class="nt"&gt;-i&lt;/span&gt; HEAD~3  &lt;span class="c"&gt;# Edit last 3 commits  &lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Inside the editor, you can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;pick&lt;/strong&gt; → Keep commit as is
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;reword&lt;/strong&gt; → Change commit message
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;edit&lt;/strong&gt; → Modify commit contents
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;squash&lt;/strong&gt; → Merge commits
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;drop&lt;/strong&gt; → Delete commit
&lt;strong&gt;When to use interactive rebasing?&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;To clean up messy commit history before pushing.&lt;/li&gt;
&lt;li&gt;To combine multiple small commits into one.&lt;/li&gt;
&lt;/ul&gt;




</description>
      <category>git</category>
    </item>
    <item>
      <title>Git for new learners</title>
      <dc:creator>Moustafa</dc:creator>
      <pubDate>Thu, 06 Mar 2025 01:02:50 +0000</pubDate>
      <link>https://dev.to/moustafaabedi/git-for-new-learners-4dkm</link>
      <guid>https://dev.to/moustafaabedi/git-for-new-learners-4dkm</guid>
      <description>&lt;h1&gt;
  
  
  Git - My Learning Journey
&lt;/h1&gt;

&lt;p&gt;I recently started learning Git, and my goal is to master it in just three days! To help myself understand it better, I'll document everything new I learn in this post as a personal reminder.&lt;/p&gt;

&lt;p&gt;Day 2 - Understanding &lt;code&gt;git merge&lt;/code&gt;&lt;br&gt;
Today, I learned about merging branches in Git. Merging allows changes from one branch to be applied to another. There are two types of merges:&lt;/p&gt;

&lt;p&gt;1- &lt;strong&gt;Fast Forward Merge&lt;/strong&gt; - This happens when the target branch hasn’t changed since the feature branch was created. Git simply moves the pointer forward to include the new changes.&lt;/p&gt;

&lt;p&gt;2- &lt;strong&gt;Non Fast Forward&lt;/strong&gt; (Three Way Merge) - If both branches have changes, Git creates a new commit that combines them.&lt;/p&gt;

&lt;p&gt;More to come as I continue learning! 🚀&lt;/p&gt;

</description>
      <category>git</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
