Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 83 additions & 57 deletions book/02-git-basics/sections/remotes.asc
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
[[_remote_repos]]
=== Working with Remotes
=== Bekerja Secara terpisah

To be able to collaborate on any Git project, you need to know how to manage your remote repositories.
Remote repositories are versions of your project that are hosted on the Internet or network somewhere.
You can have several of them, each of which generally is either read-only or read/write for you.
Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work.
Managing remote repositories includes knowing how to add remote repositories, remove remotes that are no longer valid, manage various remote branches and define them as being tracked or not, and more.
In this section, we'll cover some of these remote-management skills.
Untuk bisa berkolaborasi dalam projek apa saja di github, kamu harus tau bagaimana cara mengelola repositori terpisah (remote repository).

==== Showing Your Remotes
repositori terpisah adalah versi projek yang di hosting di internet ataupun di jaringan lainnya.

To see which remote servers you have configured, you can run the `git remote` command.(((git commands, remote)))
It lists the shortnames of each remote handle you've specified.
If you've cloned your repository, you should at least see origin – that is the default name Git gives to the server you cloned from:
Kamu bisa mempunyai beberapa repositori terpisah, yang pada umumnya, setiap dari mereka hanya bisa dibaca dan ditulis oleh kamu.

Berkolaborasi dengan orang lain melibatkan mengelola repositori terpisah dan mem-push data dan mem-pull data, dari dan kepada mereka, ketika kamu butuh untuk membagi pekerjaanmu.

Mengelola repositori terpisah termasuk mengetahui bagaimana cara menambah repositori terpisah, menghapus repositori yang tidak lagi valid, mengelola berbagai cabang repositori dan mengetahui apakah cabang tersebut sedang digunakan (tracked) atau tidak, dan lainnya.

Di bagian ini, kita akan belajar beberapa dari skill mengelola repositori terpisah.

==== Menunjukkan repositori terpisahmu

Untuk melihat server mana yang kamu konfigurasikan, kamu bisa menjalankan perintah `git remote`.(((git commands, remote))), Itu akan memberi daftar singkat nama dari tiap tiap repositori yang kamu spesifikasikan

Jika kamu meng-clone repositorimu, kamu setidaknya akan melihat origin (asal repo) - yang diberikan git sebagai nama default pada server yang telah kamu clone.

[source,console]
----
Expand All @@ -28,7 +33,7 @@ $ git remote
origin
----

You can also specify `-v`, which shows you the URLs that Git has stored for the shortname to be used when reading and writing to that remote:
Kamu juga bisa menspesifikasikan `-v` yang menunjukkanmu URLs yang diberikan git unruk menyimpan nama yang digunakan untuk membaca dan menulis ke repositori terpisah tersebut :

[source,console]
----
Expand All @@ -37,8 +42,7 @@ origin https://github.com/schacon/ticgit (fetch)
origin https://github.com/schacon/ticgit (push)
----

If you have more than one remote, the command lists them all.
For example, a repository with multiple remotes for working with several collaborators might look something like this.
Jika kamu memiliki lebih dari satu repositori terpisah,perintah tersebut akan memberikan daftarnya. Contoh, sebuah repositori dengan banyak repositori terpisah untuk dikerjakan oleh beberapa kolabolator, mungkin akan terlihat seperti ini:

[source,console]
----
Expand All @@ -56,14 +60,15 @@ origin git@github.com:mojombo/grit.git (fetch)
origin git@github.com:mojombo/grit.git (push)
----

This means we can pull contributions from any of these users pretty easily. We may additionally have permission to push to one or more of these, though we can't tell that here.
Ini artinya kita bisa melakukan pull kontribusi dari user mana saja secara mudah. kita mungkin punya izin untuk mem-push ke satu atau beberapa dari repositori tersebut, walaupun kami tidak memberitahunya disini.

Notice that these remotes use a variety of protocols; we'll cover more about this in <<_git_on_the_server>>.
Perhatikan bahwa repositori terpisah ini punya beberapa protocol, kami akan membahasnya lebih lanjut di <<_git_on_the_server>>.

==== Adding Remote Repositories
==== Menambahkan Repositori Terpisah

I've mentioned and given some demonstrations of adding remote repositories in previous sections, but here is how to do it explicitly.(((git commands, remote)))
To add a new remote Git repository as a shortname you can reference easily, run `git remote add [shortname] [url]`:
Saya menyebutkan dan memberikan beberapa demo tentang menambahkan repositori terpisah di pembahasan sebelumnya, tetapi disini akan dijelaskan bagaimana melakukannya secara jelas.(((git commands, remote)))

Untuk menambahkan repositori terpisah baru secara singkat, kamu bisa menjalankan `git remote add [nama] [url]`

[source,console]
----
Expand All @@ -77,8 +82,9 @@ pb https://github.com/paulboone/ticgit (fetch)
pb https://github.com/paulboone/ticgit (push)
----

Now you can use the string `pb` on the command line in lieu of the whole URL.
For example, if you want to fetch all the information that Paul has but that you don't yet have in your repository, you can run `git fetch pb`:
Sekarang kamu bisa menggunakan string `pb` di command line sebagai pengganti seluruh URL.

Contohnya, jika kamu ingin mengambil (fetch) semua informasi yang paul punya, tetapi ka,u belum mempunyainya di repositorimu, kamu bisa menjalankan `git fetch pb`:

[source,console]
----
Expand All @@ -92,53 +98,67 @@ From https://github.com/paulboone/ticgit
* [new branch] ticgit -> pb/ticgit
----

Paul's master branch is now accessible locally as `pb/master` – you can merge it into one of your branches, or you can check out a local branch at that point if you want to inspect it.
(We'll go over what branches are and how to use them in much more detail in <<_git_branching>>.)
cabang master repositori paul sekarang sudah bisa diakses secara lokal sebagai `pb/master`, kamu bisa menggabungkannya ke salah satu dari cabang repositorimu, atau kamu bisa memeriksa cabang repositorimu jika kamu ingin memeriksanya.


(Kita akan membahas cabang repositori(branch) dan bagaimana menggunakannya lebih detail di <<_git_branching>>.)


[[_fetching_and_pulling]]
==== Fetching and Pulling from Your Remotes
==== Mengambil dan Menarik Data dari Repositori Terpisah

As you just saw, to get data from your remote projects, you can run:(((git commands, fetch)))
Seperti yang telah kamu lihat, untuk mengambil data dari repositori terpisah, kamu bisa menjalankan perintah:(((git commands, fetch)))

[source,console]
----
$ git fetch [remote-name]
----

The command goes out to that remote project and pulls down all the data from that remote project that you don't have yet.
After you do this, you should have references to all the branches from that remote, which you can merge in or inspect at any time.
Perintah akan pergi ke repositori terpisah itu dan mengambil semua data yang belum kamu punya.

Setelah kamu melakukannya, kamu akan mempunyai referensi kepada semua cabang dari repositori terpisah, yang bisa kamu gabungkan atau kamu periksa kapan saja.

Jika kamu meng-clone sebuah repositori, perintah secara otomatis akan menambahkan repositori terpisah dibawah nama ``origin``.

Jadi, `git fetch origin` mengambil setiap pekerjaan baru yang di-push ke server tersebut sejak kamu clone(atau sejak pengambilan (fetch) terakhir),


If you clone a repository, the command automatically adds that remote repository under the name ``origin''.
So, `git fetch origin` fetches any new work that has been pushed to that server since you cloned (or last fetched from) it.
It's important to note that the `git fetch` command pulls the data to your local repository – it doesn't automatically merge it with any of your work or modify what you're currently working on.
You have to merge it manually into your work when you're ready.
Sangat penting untuk mencatat bahwa perintah `git fetch` akan mengambil data ke repositori lokalmu - tetapi ia tidak otomatis tergabung dengan pekerjaanmu atau perubahan apapun yang kamu lakukan .

If you have a branch set up to track a remote branch (see the next section and <<_git_branching>> for more information), you can use the `git pull` command to automatically fetch and then merge a remote branch into your current branch.(((git commands, pull)))
This may be an easier or more comfortable workflow for you; and by default, the `git clone` command automatically sets up your local master branch to track the remote master branch (or whatever the default branch is called) on the server you cloned from.
Running `git pull` generally fetches data from the server you originally cloned from and automatically tries to merge it into the code you're currently working on.
Kamu harus menggabungkannya secara manual ketika pekerjaanmu sudah siap.

Jika kamu mempunyai cabang yang digunakan untuk memantau sebuah repositori terpisah (lihat sesi selanjutnya dan <<_git_branching>> untuk informasi lebih lanjut), kamu bisa menggunakan perintah `git pull` untuk otomatis mengambil dan menggabungkan sebuah repositori terpisah ke cabang repositorimu saat ini.(((git commands, pull)))

Ini mungkin saja menjadi cara yang lebih mudah atau lebih nyaman bagimu; dan secara default, perintah `git clone` akan otomatis menetapkan lokal repositorimu untuk memantau master repositori terpisahmu (atau apapun nama default repositori tersebut) pada server yang kamu clone.

menjalankan `git pull` umumnya akan mengambil data dari server yang kamu clone dan secara otomatis mencoba menggabungkannya dengan kode yang sedang kamu kerjakan.

[[_pushing_remotes]]
==== Pushing to Your Remotes
==== Mem-push ke repositori terpisah

Ketika kamu punya projek yang ingin kamu bagikan, kamu harus mem-push nya secara ke atas (upstream). Perintahnya cukup mudah : `git push [remote-name] [branch-name]`.(((git commands, push)))

When you have your project at a point that you want to share, you have to push it upstream.
The command for this is simple: `git push [remote-name] [branch-name]`.(((git commands, push)))
If you want to push your master branch to your `origin` server (again, cloning generally sets up both of those names for you automatically), then you can run this to push any commits you've done back up to the server:
Jika kamu ingin mem-push cabang branch ke server `origin` (lagi, meng-clone umumnya akan menetapkan kedua nama tersebut untukmu secara otomatis), lalu kamu bisa menjalankannya untuk mem-push commit yang telah kamu selesaikan di server :

[source,console]
----
$ git push origin master
----

This command works only if you cloned from a server to which you have write access and if nobody has pushed in the meantime.
If you and someone else clone at the same time and they push upstream and then you push upstream, your push will rightly be rejected.
You'll have to pull down their work first and incorporate it into yours before you'll be allowed to push.
See <<_git_branching>> for more detailed information on how to push to remote servers.
Perintah ini hanya bekerja jika kamu meng-clone dari server yang dimana kamu punya akses menulis dan belum ada yang mem-push hingga saat itu.

Jika kamu dan orang lain meng-clone pada saat yang sama dan mereka mem-push ke atas(upstream) dan kamu juga mem-push ke atas(upstream), maka push kamu akan ditolak.

Kamu harus mem-pull pekerjaan mereka terlebih dahulu dan menggabungkannya di repositorimu sebelum kamu diperbolehkan untuk melakukan push.

Lihat <<_git_branching>> untuk informasi detail lebih lanjut tentang bagaimana mem-push ke server repositori terpisah.

[[_inspecting_remote]]
==== Inspecting a Remote
==== Memeriksa Repositori Terpisah

If you want to see more information about a particular remote, you can use the `git remote show [remote-name]` command.(((git commands, remote)))
If you run this command with a particular shortname, such as `origin`, you get something like this:
Jika kamu ingin informasi lebih lanjut tentang sebuah repositori tertentu, kamu bisa menggunakan perintah `git remote show [remote-name]` (((git commands, remote)))

kalau kamu menggunakan perintah dengan singkatan tertentu seperti `origin`, maka kamu akan mendapatkan sesuatu yang seperti ini :

[source,console]
----
Expand All @@ -156,12 +176,13 @@ $ git remote show origin
master pushes to master (up to date)
----

It lists the URL for the remote repository as well as the tracking branch information.
The command helpfully tells you that if you're on the master branch and you run `git pull`, it will automatically merge in the master branch on the remote after it fetches all the remote references.
It also lists all the remote references it has pulled down.
Itu akan membuat daftar URL untuk repositori terpisah, begitu juga begitu juga dengan pantauan informasi branch.

Perintah ini membantu memberi tahumu bahwa jika kamu sedang berada di cabang master dan menjalankan `git pull`, itu akan secara otomatis merge (menggabungkannya) di cabang master di repositori terpisah setelah di fetch semua referensi repositorinya.

That is a simple example you're likely to encounter.
When you're using Git more heavily, however, you may see much more information from `git remote show`:
Itu juga akan membuat daftar semua referensi repositori yang telah di pull.

Ini adalah contoh sederhana yang mungkin akan kamu hadapi, ketika kamu menggunakan Git lebih banyak lagi, bagaimanapun, kamu mungkin melihat lebih banyak informasi dari `git remote show`:

[source,console]
----
Expand All @@ -187,13 +208,17 @@ $ git remote show origin
master pushes to master (up to date)
----

This command shows which branch is automatically pushed to when you run `git push` while on certain branches.
Perintah ini menunjukkan cabang mana yang otomatis akan di push ketika kamu menjalankan perintah `git push` ketika berada dalam cabang tertentu.

Itu juga menunjukkanmu cabang repositori terpisah mana yang berada di servermu yang belum kamu punya, repositori terpisah mana yang telah kamu hapus dari server, dan beberapa cabang yang otomatis merge (tergabung) ketika kamu menjalankan `git pull`

It also shows you which remote branches on the server you don't yet have, which remote branches you have that have been removed from the server, and multiple branches that are automatically merged when you run `git pull`.

==== Removing and Renaming Remotes
==== Menghapus dan Mengubah Nama Repositori Terpisah

Kalau kamu ingin mengubah referensi nama, kamu bisa menjalankan `git remote rename` untuk mengubah nama dari repositori terpisah.(((git commands, remote)))

If you want to rename a reference you can run `git remote rename` to change a remote's shortname.(((git commands, remote)))
For instance, if you want to rename `pb` to `paul`, you can do so with `git remote rename`:
Contohnya, Jika kamu ingin mengubak nama `pb` ke `paul`, kamu bisa menggunakan `git remote rename`:

[source,console]
----
Expand All @@ -203,10 +228,11 @@ origin
paul
----

It's worth mentioning that this changes your remote branch names, too.
What used to be referenced at `pb/master` is now at `paul/master`.
Sangat baik untuk menyertakan bahwa ini mengubah nama cabang repositori terpisahmu juga.

Apa yang dahulunya direferensikan sebagai `pb/master` sekarang menjadi `paul/master`.

If you want to remove a remote for some reason – you've moved the server or are no longer using a particular mirror, or perhaps a contributor isn't contributing anymore – you can use `git remote rm`:
Jika kamu ingin menghapus repositori terpisahmu untuk beberapa alasan - kamu bisa memindahkan server atau tidak lagi menggunakan `mirror` tertentu, atau mungkin seorang kontributor tidak berkontribusi lagi - kamu bisa menggunakan perintah `git remote rm`:

[source,console]
----
Expand Down