GIT: Solving conflicts

Banyak orang yang bosan dengan konflik. Bukan konflik rumah tangga — walopun konflik rumah tangga juga membosankan — akan tetapi konflik pada source code mereka.

Setelah kemarin saya menulis tentang mengabaikan perubahan pada tracked files, sekarang saya ingin berbagi tentang solving git conflicts menggunakan command line menggunakan code dari remote branch dan mengabaikan code dari local kita.

learn git
Learn GIT: Solving conflicts

Contoh kasus: Anda melakukan pull dari upstream, namun ternyata ada conflict dalam code yang Anda pull dan code dari branch lokal Anda, biasanya muncul notifikasi seperti ini:

Untuk itu, dengan menganggap bahwa code kita tidak update, maka secara default saya menggunakan perubahan dari upstream. Caranya adalah dengan menggunakan command berikut:

Command ini berarti melakukan pull menggunakan strategi merging theirs dari remote branch.

Demikian, semoga bermanfaat  :)

GIT: Mengabaikan Perubahan pada Tracked File

Terkadang kita banyak menemui kasus-kasus dalam khusus dalam menggunakan git. Salah satu yang saya alami adalah menggunakan dropbox sebagai git server kita, dalam kebutuhan kita, kadang kita menemui kasus seperti ini:

Dalam project yang sedang kita kerjakan bersama tim, ada file konfigurasi config.ini, yang mana file tersebut sudah masuk ke dalam list tracked file, agar project dapat berjalan di sistem lokal kita, kita harus mengubah file tersebut, akan tetapi perubahan ini tidak dapat kita push ke git server karena ini setting dari komputer lokal Anda tidak boleh ikut di push kedalam git server, karena akan mempengaruhi file project teman-teman satu tim Anda apabila mereka melakukan pull.

Kenapa tidak dimasukkan ke dalam .gitignore saja? Apabila kita memasukkan file tersebut ke dalam .gitignore maka file ini akan diignore oleh project secara keseluruhan. Jadi tentu saja kita tidak dapat memasukkan file tersebut kedalam .gitignore

Untuk mengatasi hal itu maka sebaiknya kita menggunakan

Dengan begitu semua perubahan yang terjadi pada file itu akan diasumsikan tidak berubah oleh git.

Kemudian, bagaimana cara mengembalikannya dong? Tenang, itu juga sudah dipikirkan dengan menggunakan:

That’s it. Happy coding folks!

Using dropbox as another remote repository for your Projects

I work on two different computers:
A PC on my office, and a personal lapton on my home.
Using these two computers, usually I work on a same single-project.

The problem with this setup is, I cannot continue to work on files where I left those files on my office computer.
The changes I made on my office computer dont magicly appear on my laptop like I hope 😛
Usually for a small project without complex file directories, I can just sync them with Dropbox.

But for this particular project, I cant use it because the configuration on my office computer which using Ubuntu
and my laptop which using arch-linux as its OS, is different, so I cant just sync it with Dropbox.

You use git, right? so why dont You just push your changes from your office and just pull it from home?
Yes, I use GIT, but we should not push commit that generate error and cannot be build up there.
Yet I cant just make a new branch on our git server because it’ll make a lot of junk files that will be pulled by
other people on my team.

Then I think about this solution.

I will make a new git remote repository on my dropbox folder and push my project files there.
and push my personal changes there, so that I can the changes from home.
And on my home I still can pull the changes on my working git server and still can pull changes I make on my personal-changes-repository
On my home-laptop I will only push to dropbox folder.

So this is my documented step-by-step:

First, make an git init on your dropbox folder

Here I will use my .vim repository located on github

Then I will add a readme file

change to a new experiment branch

now it’s time to add the remote dropbox

push your experiment branch to the dropbox repo

add the upstream
[[email protected] .vim]$ git push –set-upstream dropbox-vim experiment

commit your changes

and push it

And on your home computer

On the git log, as proof the files has been synced:

Voila! Now i can work on those two machine :)

SCM Yang Kamu Gunakan

Apakah anda menggunakan Software SCM (kependakan dari Source Code Management)

Saya tidak memiliki banyak pengalaman mendalam mengenai scm ini, saya hanya sebatas mencoba berbagai softwarenya yang tersebar bebas di internet. Saat ini saya menggunakan GIT karena sudah merasa nyaman dengan GIT, dan kebetulan ditempat saya bekerja saat ini pun menggunakan GIT, klop lah. Apalagi ada beberapa hal yang bisa dilakukan git namun tidak dapat dilakukan oleh scm lain.

GIT buatan Linus Torvalds ini semenjak adanya Github, seakan menjadi standar di versioning di dunia internet. Kebanyakan orang yang melakukan sharing code, pasti menggunakan url ke link github yang mereka punyai, bahkan tidak hanya itu saja, web besar berbasis tanya jawab seperti StackOverflow di web Carreer-nya pun menggunakan github sebagai salah satu pengecekan standar kalo anda ingin menjual karir anda, tim stackoverflow akan melihat code di github anda apakah anda cukup pantas untuk menawarkan kemampuan Anda di web career meraka. Btw, dengan berbagi code di github, berarti anda juga berkontribusi kepada dunia open source.

Jadi, scm apa yang anda gunakan?

The Viva la Vida Song Story

Because i like Coldplay’s song Viva La Vida, i’d like to share a story about it.

This explanation was taken from quora

The song is essentially putting itself in the shoes of Louis XVI and the theme
is his transition from ultimate power to his death. He was found guilty of
treason and eventually beheaded.

“I used to rule the world
Seas would rise when I gave the word
Now in the morning I sleep alone
Sweep the streets I used to own”

This first stanza is to show how he used to have immense power over everyone
to the point where “seas would rise when he gave the word”, but that he
eventually turned into somewhat of a slave, servant, or beggar in which he has
to “sweep the streets” as he is begging for mercy from the people.

“I used to roll the dice
Feel the fear in my enemy’s eyes
Listened as the crowd would sing
Now the old king is dead long live the king”

He then talks about rolling the dice — gambling with power and how that
eventually led the people to rejoice over the fact that the old king is now
dead because he was a tyrant and crusader and his ruling would soon be

“One minute I held the key
Next the walls were closed on me
And I discovered that my castles stand
Upon pillars of salt and pillars of sand”

The “minute” connotes that everything happened so very fast that Louis XVI
didn’t even realize it until his castles, which represent his power, fell so
quickly because of its poor foundation (salt and sand) and that the walls were
soon closed.

“I hear Jerusalem bells a-ringing
Roman cavalry choirs are singing
Be my mirror my sword and shield
Missionaries in a foreign field”

He frequently used religion to cover up his corruption and his doings so that
explains the “missionaries in a foreign field” and the fact that he kept
implementing conquest to raid other nations in the name of Christianity.

“For some reason I can’t explain
Once you’d gone there was never
Never an honest word
And that was when I ruled the world”

Because he was so caught up with the power he had, he never told a word of the
truth when he ruled. He kept lying to his people, drunk with power, money, and

“It was a wicked and wild wind
Blew down the doors to let me in
Shattered windows and the sound of drums
People couldn’t believe what I’d become”

There is a story that when Louis XVI was walking up to the beheading device,
he tried to say something to the people but the drums were too loud so no one
could hear him. This could be what the “sound of drums” is suggesting. People
also couldn’t believe what they had let Louis become: an absolute tyrant.

“Revolutionaries wait
For my head on a silver plate
Just a puppet on a lonely string
Oh who would ever want to be king?”

“Revolutonaries” suggest people who wanted him to be killed in which it goes
on to say that they are waiting for his head on a silver plate which can only
mean one thing: the guillotine. The guillotine was a beheading device that
Louis was killed on.

“For some reason I can’t explain
I know St Peter won’t call my name”
Never an honest word
But that was when I ruled the world”

Even though Louis claimed to be fighting in the name of Christianity, he knows
himself that St. Peter, the gatekeeper of Heaven will not welcome him because
he is going to hell for all that he has committed.

Theme: Absolute power corrupts absolutely.

BMP vs GIF vs JPEG vs PNG Best Use

I my self usually doesnt care about what best image type to use, here is a thread from stackoverflow with good explanation — i modified a little bit

When should certain image filetypes be used? E.g. On websites, interfaces, etc?

You should be aware of a few key factors…

First, there are two types of compression: Lossless and Lossy.

Lossless means that the image is made smaller, but at no detriment to the quality. Lossy means the image is made (even) smaller, but at a detriment to the quality. If you saved an image in a Lossy format over and over, the image quality would get progressively worse and worse.

There are also different colour depths (palettes): Indexed color and Direct color.

With Indexed it means that the image can only store a limited number of colours (usually 256) that are chosen by the image author, with Direct it means that you can store many thousands of colours that have not been chosen by the author.

BMP – Lossless / Indexed and Direct

This is an old format. It is Lossless (no image data is lost on save) but there’s also little to no compression at all, meaning saving as BMP results in VERY large file sizes. It can have palettes of both Indexed and Direct, but that’s a small consolation. The file sizes are so unnecessarily large that nobody ever really uses this format.

Good for: Nothing really. There isn’t anything BMP excels at, or isn’t done better by other formats.


GIF – Lossless / Indexed only

GIF uses lossless compression, meaning that you can save the image over and over and never lose any data. The file sizes are much smaller than BMP, because good compression is actually used, but it can only store an Indexed palette. This means that there can only be a maximum of 256 different colours in the file. That sounds like quite a small amount, and it is.

GIF images can also be animated and have transparency.

Good for: Logos, line drawings, and other simple images that need to be small. Only really used for websites.


JPEG – Lossy / Direct

JPEGs images were designed to make detailed photographic images as small as possible by removing information that the human eye won’t notice. As a result it’s a Lossy format, and saving the same file over and over will result in more data being lost over time. It has a palette of thousands of colours and so is great for photographs, but the lossy compression means it’s bad for logos and line drawings: Not only will they look fuzzy, but such images will also have a larger file-size compared to GIFs!

Good for: Photographs. Also, gradients.


PNG-8 – Lossless / Indexed

PNG is a newer format, and PNG-8 (the indexed version of PNG) is really a good replacement for GIFs. Sadly, however, it has a few drawbacks: Firstly it cannot support animation like GIF can (well it can, but only Firefox seems to support it, unlike GIF animation which is supported by every browser). Secondly it has some support issues with older browsers like IE6. Thirdly, important software like Photoshop have very poor implementation of the format. (Damn you, Adobe!) PNG-8 can only store 256 colours, like GIFs.

Good for: The main thing that PNG-8 does better than GIFs is having support for Alpha Transparency.

PNG-8 vs GIF

Important Note: Photoshop does not support Alpha Transparency for PNG-8 files. (Damn you, Photoshop!) There are ways to convert Photoshop PNG-24 to PNG-8 files while retaining their transparency, though. One method is PNGQuant, another is to save your files with Fireworks.

PNG-24 – Lossless / Direct

PNG-24 is a great format that combines Lossless encoding with Direct color (thousands of colours, just like JPEG). It’s very much like BMP in that regard, except that PNG actually compresses images, so it results in much smaller files. Unfortunately PNG-24 files will still be much bigger than JPEGs, GIFs and PNG-8s, so you still need to consider if you really want to use one.

Even though PNG-24s allow thousands of colours while having compression, they are not intended to replace JPEG images. A photograph saved as a PNG-24 will likely be at least 5 times larger than a equivalent JPEG image, which very little improvement in visible quality. (Of course, this may be a desirable outcome if you’re not concerned about filesize, and want to get the best quality image you can.)

Just like PNG-8, PNG-24 supports alpha-transparency, too.

I hope that helps!

Taken from stackoverflow forum for reminder to myself. Link