<?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: Ammar Omari</title>
    <description>The latest articles on DEV Community by Ammar Omari (@ammar7077).</description>
    <link>https://dev.to/ammar7077</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%2F1206899%2F1fc94b46-0b5e-4e76-a72e-15b8f401a8b0.jpeg</url>
      <title>DEV Community: Ammar Omari</title>
      <link>https://dev.to/ammar7077</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ammar7077"/>
    <language>en</language>
    <item>
      <title>All You Need to Know: Popular Tools for Git and GitHub</title>
      <dc:creator>Ammar Omari</dc:creator>
      <pubDate>Fri, 22 Dec 2023 15:41:44 +0000</pubDate>
      <link>https://dev.to/ammar7077/all-you-need-to-know-popular-tools-for-git-and-github-1066</link>
      <guid>https://dev.to/ammar7077/all-you-need-to-know-popular-tools-for-git-and-github-1066</guid>
      <description>&lt;p&gt;The provided content is a detailed guide that covers various aspects of using Git for version control. It includes instructions for setting up user configurations, initializing a Git repository, managing remotes, adding files, making commits, checking changes, viewing commit logs, pushing to existing repositories, creating new repositories, cloning, pulling, branching, undoing commits, stashing changes, merging branches, and counting commits.&lt;/p&gt;

&lt;p&gt;This guide is likely to be helpful for users who are new to Git and GitHub or those looking for a comprehensive reference for common Git commands and workflows. It provides step-by-step instructions along with explanations for each command, making it accessible for users at different skill levels.&lt;/p&gt;

&lt;p&gt;If the goal is to help users employ version control effectively, this guide can be a valuable resource as it covers a wide range of Git-related tasks commonly encountered in software development projects. The inclusion of links to additional resources at the end adds to the completeness of the guide.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;GIT Download url:&lt;/strong&gt; &lt;a href="https://git-scm.com/downloads"&gt;Git-Downloads&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Username and Email:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Check your username and email, for the current project
$ git config user.name
$ git config user.email
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Set username and email, for the current project
$ git config user.name &amp;lt;YOUR_USERNAME&amp;gt;
$ git config user.email &amp;lt;YOUR_EMAIL&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Check your username and email, for all the projects in the device
$ git config --global user.name
$ git config --global user.email
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Set username and email global, for all the projects in the device
$ git config --global user.name &amp;lt;YOUR_USERNAME&amp;gt;
$ git config --global user.email &amp;lt;YOUR_EMAIL&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Add Git to your project:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Remote:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;List remote branches:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git remote -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remote public:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git remote add "&amp;lt;REMOTE_NAME&amp;gt;” &amp;lt;REPO_URL&amp;gt;

# ----- OR

$ git remote add origin &amp;lt;REPO_URL&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remote a repo/private repo:
Open GitHub Account → Settings → Developer Settings → Personal access tokens - Tokens (classic) → Generate new token (classic)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# it will remove current remote and set another one
$ git remote set-url origin https://&amp;lt;token&amp;gt;@github.com/&amp;lt;username&amp;gt;/&amp;lt;repo&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remove remote:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Removing current remote and set another one
$ git remote set-url origin git://&amp;lt;NEW_URL_HERE&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Just remove remote
$ git remote remove origin

# ----- OR

$ git remote remove &amp;lt;REMOTE_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Add files for commit/push/stash…:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All files:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git add .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Single file:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git add &amp;lt;FILE_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Make a commit:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git commit -m “&amp;lt;YOUR_COMMIT&amp;gt;”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Check the changes:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Check commit logs:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git log
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;How to Push to an existing repository (GitHub):&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdkjim6o7p6sd5yuz0m9y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdkjim6o7p6sd5yuz0m9y.png" alt="Image description" width="800" height="186"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# “git init” no need: if you have a git folder in your project … file named “.get”
$ git init 
$ git remote add origin git@github.com:&amp;lt;USERNAME&amp;gt;/&amp;lt;REPO_NAME&amp;gt;.git
$ git add .
$ git commit -m "&amp;lt;YOUR_COMMIT&amp;gt;"
$ git push -u origin main

# ------- OR

$ git remote add origin git@github.com:&amp;lt;USERNAME&amp;gt;/&amp;lt;REPO_NAME&amp;gt;.git
$ git add .
$ git commit -m "&amp;lt;YOUR_COMMIT&amp;gt;"
$ git push -u origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;How to Create a New Repository and Push the project (GitHub):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open GitHub and create a new repo from “Repositories”:
&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2yxhpgf0e09iwttkusq2.png" alt="Image description" width="800" height="63"&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Open your project that you want to push it&lt;/li&gt;
&lt;li&gt;Right click on empty place and open “Git Bash Here”&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git init
# change from master branch to main branch
$ git branch -M main
$ touch README.md # optional
$ git add README.md # optional
$ git add .
$ git commit -m "first commit"
$ git remote add origin git@github.com:&amp;lt;USERNAME&amp;gt;/&amp;lt;REPO_NAME&amp;gt;.git
$ git push -u origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Clone:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clone public repo:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone &amp;lt;REPO_URL&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Clone Private repo:
Open GitHub Account → Settings → Developer Settings → Personal access tokens - Tokens (classic) → Generate new token (classic)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone https://&amp;lt;TOKEN&amp;gt;@github.com/&amp;lt;USERNAME&amp;gt;/&amp;lt;REPO_NAME&amp;gt;.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Push the commits
$ git push
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# “git pull” is a combination of “git fetch” and “git merge”
$ git pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# List local branches
$ git branch

# List all branches local and remote, (the connected branches = Red color)
$ git branch -a

# Create a new local branch
$ git branch &amp;lt;BRANCH_NAME&amp;gt;

# Delete a local branch (if merged)
$ git branch -d &amp;lt;BRANCH_NAME&amp;gt;

# Delete local branch (force, regardless of merge status), even if it’s merged or not
$ git branch -D &amp;lt;BRANCH_NAME&amp;gt;

# Move from the current branch to the existing branch
$ git checkout &amp;lt;EXISTING_BRANCH_NAME&amp;gt;

# Create and switch to a new local branch: Take the changes from the current branch and move it to the new branch
$ git checkout -b &amp;lt;NEW_BRANCH_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;List current commit history:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Undo commit:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Undo last commit:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git reset --soft HEAD~1
# OR
$ git revert HEAD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Undo to specific commit:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git reflog
$ git revert &amp;lt;ID&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;List current commit history:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git reflog
$ git revert &amp;lt;ID&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# List of stashes:
$ git stash list

# Add to stash:
$ git stash

# Apply specific stash index
$ git stash apply stash@{&amp;lt;INDEX&amp;gt;}

# Retrieve last stash Recommended:
$ git stash apply

# Retrieve last stash NOT recommended:
$ git stash pop

# Retrieve a specific stash:
$ git stash apply stash@{&amp;lt;INDEX&amp;gt;}

# Remove a single stashed state from the stash list:
$ git stash drop stash@{&amp;lt;INDEX&amp;gt;}

# Remove last stash:
$ git stash drop

# Remove all stashed files at once:
$ git stash clear
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git merge &amp;lt;BRANCH_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Count Commits:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git shortlog -s
$ git shortlog -s -n
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;More:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/git-guides"&gt;GitHub: Git-Guides&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My GitHub:&lt;/strong&gt; &lt;a href="https://github.com/Ammar7077"&gt;Ammar7077&lt;/a&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>versioncontrol</category>
    </item>
  </channel>
</rss>
