<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.0">Jekyll</generator><link href="https://chandrawijaya.com/feed.xml" rel="self" type="application/atom+xml" /><link href="https://chandrawijaya.com/" rel="alternate" type="text/html" /><updated>2021-02-28T13:18:51+00:00</updated><id>https://chandrawijaya.com/feed.xml</id><title type="html">chandrawijaya.com</title><author><name>Y Chandra Wijaya</name><email>ychandra.w@gmail.com</email></author><entry><title type="html">Common Git Commands Line</title><link href="https://chandrawijaya.com/reference/2021/02/21/common-git-command.html" rel="alternate" type="text/html" title="Common Git Commands Line" /><published>2021-02-21T00:00:00+00:00</published><updated>2021-02-21T00:00:00+00:00</updated><id>https://chandrawijaya.com/reference/2021/02/21/common-git-command</id><content type="html" xml:base="https://chandrawijaya.com/reference/2021/02/21/common-git-command.html">&lt;p&gt;Git has so many command line which we can used. Remember all of them would be a waste to our brain memory. When we frequently use the common Git commands line, those will be stored somewhere deep down under our concious.&lt;/p&gt;

&lt;p&gt;I just want to list down what are the common git commands line which i frequently used for my reference usage on github and hopefully you get the benefit of it as well.&lt;/p&gt;

&lt;h2 id=&quot;common-git-commands&quot;&gt;Common Git Commands&lt;/h2&gt;
&lt;h3 id=&quot;git-clone&quot;&gt;git clone&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;git clone&lt;/em&gt; command used to copy existing remote repository and create a local working copy of it. What &lt;em&gt;git clone&lt;/em&gt; does, it will:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Copy the remote repository files and folders to our local computer,&lt;/li&gt;
  &lt;li&gt;Automatically create a remote connection called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;origin&lt;/code&gt; which pointing back to original remote repository. This remote connection is established by creating Git refs to the remote branch heads under &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;refs/remotes/origin&lt;/code&gt; and by initializing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;remote.origin.url&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;remote.origin.fetch&lt;/code&gt; configuration variables.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Command:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git clone &amp;lt;remote_URL&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;remote_URL&amp;gt;&lt;/code&gt; commonly use the &lt;em&gt;https&lt;/em&gt; protocol. Example: https://github.com/xyz/xyz.github.io.git&lt;/p&gt;

&lt;p&gt;Sample Usage:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git clone https://github.com/xyz/xyz.github.io.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The outcome of above command is to copy the remote repository to the current folder and creating a new folder called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xyz.github.io.git&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you want to clone it to specific folder location, you could specified the folder name at behind. Example:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git clone https://github.com/xyz/xyz.github.io.git my_folder
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;hr /&gt;

&lt;h3 id=&quot;git-config&quot;&gt;git config&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;git config&lt;/em&gt; command used to set the configuration or setting for ‘git’. Configuration names are &lt;em&gt;dot delimited strings&lt;/em&gt; composed of a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;section&lt;/code&gt; and a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;key&lt;/code&gt; based on their hierarchy. There are 2 most important setting for git which are &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user.name&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;user.email&lt;/code&gt;. These settings set the user name and the user email used when commits from local computer.&lt;/p&gt;

&lt;p&gt;Command:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git config &amp;lt;setting&amp;gt; &amp;lt;&lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Sample Usage:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git config user.name &lt;span class=&quot;s2&quot;&gt;&quot;chandra.wijaya&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git config user.email &lt;span class=&quot;s2&quot;&gt;&quot;chandra.wijaya@xyz.com&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;There is a configuration levels which defined as arguments to specify which configuration level to operate on. There are 3 configuration levels as below:&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--local&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As default, if when we dont specify an argument, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git config&lt;/code&gt; command will write to local level and it will apply only to the current local repository that you are currently in.&lt;/p&gt;

&lt;p&gt;Local configuration values are stored in a local repository folder &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.git&lt;/code&gt; directory on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.git/config&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--global&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--global&lt;/code&gt; argument is used to write the git settings to &lt;strong&gt;all repositories&lt;/strong&gt; for a operating system user local computer. Global configuration values are stored in a file that is located in a user’s home directory. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.gitconfig&lt;/code&gt; on unix systems and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\Users\\.gitconfig&lt;/code&gt; on windows system.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--system&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;A &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--system&lt;/code&gt; argument is used to write the git settings to &lt;strong&gt;all repositories&lt;/strong&gt; on a local computer globally. This argument apply to &lt;strong&gt;all operating system users&lt;/strong&gt; and &lt;strong&gt;all repositories&lt;/strong&gt; inside that local computer.&lt;/p&gt;

&lt;p&gt;The system level configuration file stored in a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gitconfig&lt;/code&gt; file off the system root path. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$(prefix)/etc/gitconfig&lt;/code&gt; on unix systems. On windows this file can be found at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\Documents and Settings\All Users\Application Data\Git\config&lt;/code&gt; on Windows XP, and in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\ProgramData\Git\config&lt;/code&gt; on Windows Vista and newer.&lt;/p&gt;

&lt;p&gt;The priority sequence order for above 3 configuration levels as below:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;local&lt;/li&gt;
  &lt;li&gt;global&lt;/li&gt;
  &lt;li&gt;system&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This has a meaning that  when looking for a configuration value, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Git config&lt;/code&gt; will start at the 1st local level, then only 2nd global level and last is system level.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;git-init&quot;&gt;git init&lt;/h3&gt;
&lt;p&gt;When first time we create a local directory without using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;clone&lt;/code&gt; method above, we need to initiate &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git init&lt;/code&gt; command to turn that local directory into an &lt;strong&gt;empty Git repository&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This is the first step in creating a local repository. After that, we can continue with next git command by adding and committing local files / directories inside that local directory.&lt;/p&gt;

&lt;p&gt;Command:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# change directory to my_folder&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /Users/computer-name/Documents/my_folder

&lt;span class=&quot;c&quot;&gt;# make my_folder directory a git repository&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git init
Initialized empty Git repository &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; /Users/computer-name/Documents/my_folder/.git/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;hr /&gt;

&lt;h3 id=&quot;git-add&quot;&gt;git add&lt;/h3&gt;
&lt;p&gt;To add files into staging area (Git index) for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git&lt;/code&gt; we use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git add&lt;/code&gt; command. There are different ways to use this command depending on what we want to achieve. We can add entire directories, add specific files, or even all unstaged files with this &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git add&lt;/code&gt; command.&lt;/p&gt;

&lt;p&gt;Command:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git add &amp;lt;file or directory name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Sample Usage:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# To add all files not staged in current directory:&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git add &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# To add an index.html file only:&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git add index.html

&lt;span class=&quot;c&quot;&gt;# To add an entire html directory:&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git add html
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;hr /&gt;

&lt;h3 id=&quot;git-commit&quot;&gt;git commit&lt;/h3&gt;
&lt;p&gt;Use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git commit&lt;/code&gt; command to record the changes made on the files/directories to a local repository. Each &lt;strong&gt;commit&lt;/strong&gt; has a unique ID for the purpose of easy reference. There is best practice that we include a message for each commit, to explain what are the changes made on that commit for better understanding and help to find the specific changes we have done earlier in the future.&lt;/p&gt;

&lt;p&gt;Command:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# Adding a commit with message&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git commit &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Commit message in quotes&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Sample Usage:&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git commit &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;My first commit message&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name>Y Chandra Wijaya</name><email>ychandra.w@gmail.com</email></author><category term="reference" /><category term="github" /><category term="git" /><summary type="html">Git has so many command line which we can used. Remember all of them would be a waste to our brain memory. When we frequently use the common Git commands line, those will be stored somewhere deep down under our concious.</summary></entry><entry><title type="html">Welcome to Jekyll!</title><link href="https://chandrawijaya.com/blog/2021/01/01/welcome-to-jekyll.html" rel="alternate" type="text/html" title="Welcome to Jekyll!" /><published>2021-01-01T00:00:00+00:00</published><updated>2021-01-01T00:00:00+00:00</updated><id>https://chandrawijaya.com/blog/2021/01/01/welcome-to-jekyll</id><content type="html" xml:base="https://chandrawijaya.com/blog/2021/01/01/welcome-to-jekyll.html">&lt;p&gt;You’ll find this post in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_posts&lt;/code&gt; directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jekyll serve&lt;/code&gt;, which launches a web server and auto-regenerates your site when a file is updated.&lt;/p&gt;

&lt;p&gt;To add new posts, simply add a file in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_posts&lt;/code&gt; directory that follows the convention &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YYYY-MM-DD-name-of-post.ext&lt;/code&gt; and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.&lt;/p&gt;

&lt;p&gt;Jekyll also offers powerful support for code snippets:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;print_hi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hi, &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;print_hi&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Tom'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;#=&amp;gt; prints 'Hi, Tom' to STDOUT.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Check out the &lt;a href=&quot;https://jekyllrb.com/docs/home&quot;&gt;Jekyll docs&lt;/a&gt; for more info on how to get the most out of Jekyll. File all bugs/feature requests at &lt;a href=&quot;https://github.com/jekyll/jekyll&quot;&gt;Jekyll’s GitHub repo&lt;/a&gt;. If you have questions, you can ask them on &lt;a href=&quot;https://talk.jekyllrb.com/&quot;&gt;Jekyll Talk&lt;/a&gt;.&lt;/p&gt;</content><author><name>Y Chandra Wijaya</name><email>ychandra.w@gmail.com</email></author><category term="blog" /><category term="Jekyll" /><category term="update" /><summary type="html">You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve, which launches a web server and auto-regenerates your site when a file is updated.</summary></entry></feed>