<?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: Bratipah</title>
    <description>The latest articles on DEV Community by Bratipah (@bratipah).</description>
    <link>https://dev.to/bratipah</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%2F747795%2Fe13750c0-89c6-4e3d-b462-3ff7084494d5.jpeg</url>
      <title>DEV Community: Bratipah</title>
      <link>https://dev.to/bratipah</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bratipah"/>
    <language>en</language>
    <item>
      <title>GIT; VersioN ControL SysteM</title>
      <dc:creator>Bratipah</dc:creator>
      <pubDate>Tue, 30 Nov 2021 10:36:27 +0000</pubDate>
      <link>https://dev.to/bratipah/git-version-control-system-4ga2</link>
      <guid>https://dev.to/bratipah/git-version-control-system-4ga2</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IeJDS0WJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/748mgznsk4z19t0ul9sf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IeJDS0WJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/748mgznsk4z19t0ul9sf.jpg" alt="Image description" width="612" height="612"&gt;&lt;/a&gt;Imagine in a scenario where there wasnt any github. What were developers using to collaborate with? It goes wth doubt that most people think that the only version control system available is github.Am i wrong? What is a version control system? &lt;/p&gt;

&lt;p&gt;Welcome to my first technical based blog....&lt;/p&gt;

&lt;p&gt;A version control system is a category of software tools that helps in recording changes made to files by keeping a track of modifications done to the code. These changes maybe include removing or adding lines of code to the source code between a group of developers in disregard of their geographical location. If a mistake is made developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members.&lt;/p&gt;

&lt;p&gt;The first Version Control System was created in 1972 at Bell Labs where they developed UNIX. The first one was called SCCS. It was available only for UNIX and only worked with Source Code files. Both SCCS and RCS only worked on the development system and were not for sharing code, as they only worked for a single user.Verson cotrol system has two types central and dstrubuted system dfferentated by the number of repostores each has. Examples of version control systems are Git, hackmoon, apache, mecurial, AWS code commit among others. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ghlNEQtB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/osbz86781cjzoztgdlhs.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ghlNEQtB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/osbz86781cjzoztgdlhs.jpeg" alt="Image description" width="880" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Git will be the main version control system focus for now. Git is a version control system that lets you manage and keep track of your source code history. While there are some great git GUIs (graphical user interfaces), it's easier to learn git using git-specific commands first and then to try out a git GUI once you're more comfortable with the command.&lt;br&gt;
The steps to being comfortable working with git are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Install git and Create a github account&lt;br&gt;
Git and github are different in that git is open-source, version control tool while github uses git to integration &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cloning a Repository&lt;br&gt;
This one is simple in itself. You just created a repository and you want to clone it on your machine. Just run:&lt;br&gt;
git clone &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Adding a Repository Into an Existing Project&lt;br&gt;
Let's say you already are working on a project and decided later on to create a repository for it. How do you add the repository to it?&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
git add .
git commit -m "Initial Commit"
git remote add origin &amp;lt;REPOSITORY_GIT_URL&amp;gt;

If the repository you are adding is empty, you can just run:

git push origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;If, however, the repository has some files in it, I suggest you run this first:&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 origin master
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run the push command.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Get Changes from Repository
To get changes from a repository:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git pull origin master
Undo Add Command
If you ran:

git add &amp;lt;files&amp;gt;
or

git add .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then you realized that you made a mistake and you don't want to actually add those files, just run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git reset &amp;lt;files&amp;gt;
This will undo adding specific files. If you want to undo adding all files:
&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;git reset
Undo Latest Commit
You made a commit, then realized something is wrong with it. To undo it, simply run:

git reset ~HEAD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also run:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;The difference is that git revert will add a new commit that reverts the latest commit. It's probably more helpful if you've pushed the commit that you want to undo.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Edit Latest Commit
To edit the last commit or the last commit message, run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit --amend -m "new message"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remove Local Changes
If you made changes locally and you don't want them anymore for one reason or another, you can revert them back to their latest version in your Git Repository by running:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;To remove local changes of specific files instead of all changes you can run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout &amp;lt;files&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Create a Branch
To create a new branch:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch &amp;lt;NEW_BRANCH&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Switch Branches
To switch from one branch to another:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;p&gt;Create a New Branch And Switch To It&lt;br&gt;
To create a new branch and switch to it immediately, you can run:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Delete a Branch
To delete a branch:
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Merge Branches
To merge a branch to another, switch to the branch you want to merge to then run:
&lt;/li&gt;
&lt;/ul&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;"Stash" Your Local Changes&lt;br&gt;
Sometimes you might have changes locally, but you are not ready to commit them. If you need to work on something else in the meantime, go back to the original state of the repository, or change branches without losing changes, you can "stash" those changes for later:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then, when you want to pull out those changes again, just run:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Running this command will apply the latest changes you put in the stash and then remove it from the stash.&lt;/p&gt;

&lt;p&gt;If you have a lot of changes that you've "stashed", you can check them by running:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Then, you can apply a stash from the list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git stash apply &amp;lt;STASH_NAME&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set Your Email and Name In The Configurations&lt;br&gt;
You can do this on a global scope and on a repository's scope. These commands will work on a global scope just by adding the --global option.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To set the email:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git config user.email "YOUR_EMAIL"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;To set the name:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git config user.name "YOUR_NAME"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Remove Files From a Git Repository
To remove files from a Git Repository:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rm &amp;lt;files&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To remove those files only from Git without removing them locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git rm --cached &amp;lt;files&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To remove directories just add the -r option.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>github</category>
      <category>git</category>
      <category>devjournal</category>
    </item>
  </channel>
</rss>
