> For the complete documentation index, see [llms.txt](https://rafli-ramadhan.gitbook.io/golang-example-code-by-topic/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rafli-ramadhan.gitbook.io/golang-example-code-by-topic/git-command.md).

# Git Command

## Contoh command untuk membuat git repository di local

Langkah pertama, buat repository di github.com. Lalu jalankan command berikut.

```
git init                                 // untuk inisiasi repository git
git add README.md                        // pastikan sudah ada file README.md
git commit -m "first commit"             // untuk menambahkan perubahan code beserta message-nya
git branch -M main                       // untuk membuat branch master baru atau memperbaruhi nama branch master menjadi main
git remote add origin link_repository    // untuk menambahkan remote repository dari github.com
git push -u origin main                  // untuk mengirim perubahan code ke remote repository dan branch yang dituju
```

Contoh ekseskusi command di atas.

<figure><img src="/files/Aw2C2L970L4PnR5Zw70C" alt=""><figcaption></figcaption></figure>

## Contoh command untuk menambahkan remote repository di local project

Asumsikan di suatu folder sudah ada beberapa file kodingan. Kemudian jalankan command berikut.

```
git remote add origin https://github.com/rafli-ramadhan/TestGit.git
git branch -M main
git push -u origin main
```

Command -u pada git push -u origin main digunakan untuk set upstream remote dan branch yaitu origin dan main. Selanjutnya jika command git pull dan git push di jalankan, maka akan otomatis melakukan pull dan push pada remote dan branch yang di set di awal yaitu origin dan main.

<figure><img src="/files/fMWbHKjvGVmLvwhd2brY" alt=""><figcaption></figcaption></figure>

Referensi:

{% embed url="<https://stackoverflow.com/questions/5561295/what-does-git-push-u-mean>" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://rafli-ramadhan.gitbook.io/golang-example-code-by-topic/git-command.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
