Skip to content

Commit

Permalink
Adds commit exercise
Browse files Browse the repository at this point in the history
  • Loading branch information
nosknut committed Jul 19, 2023
1 parent 8d04dc5 commit ee05ba0
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 0 deletions.
102 changes: 102 additions & 0 deletions Exercises/commit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[<-- Tilbake](/README.md)

# Commit

Git er basert på commits, som består av filendringer. Et git repository består av mange commits i en bestemt rekkefølge. Under er et eksempel av hvordan en slik historikk kan se ut.

```mermaid
---
title: Git History
---
gitGraph
commit id: "Adds a print"
commit id: "Adds a second print"
commit id: "Adds a third print"
commit id: "Removes the third print"
```

### Diff for hver enkelt commit

Forskjellene mellom to commits kalles en diff. Under er diffen for hver enkelt commit i eksempelet over.

### Adds a print

```diff
+ print("Hello World!")
```

### Adds a second print

```diff
print("Hello World!")
+ print("Hello World 2!")
```

### Adds a third print

```diff
print("Hello World!")
print("Hello World 2!")
+ print("Hello World 3!")
```

### Removes the third print

```diff
print("Hello World!")
print("Hello World 2!")
- print("Hello World 3!")
```

## Summen av alle commits

```diff
print("Hello World!")
print("Hello World 2!")
```

## Lage et commit

Når du har gjennomført [Logikk](/Exercises/Logic/README.md) øvingen, har du mest sannsynlig endret noen av filene. Du kan hvilke filer du har endret i Source Control fanen. Trykk på en fil for å se hva du har endret.

![Source Control](assets/source-control.png)

Hvis du trykker på eller holder musen over en av filene , får du opp disse knappene. Pilen fjerner endringene, og pluss knappen vil flytte endringene fra "Changes" til "Staged Changes". Kun endringer i "Staged Changes" vil bli med i et commit.

![Stage button](assets/stage-button.png)

Når du har lagt til endringene, skriv en beskrivelse av hva du har gjort i "Message" feltet. Når du er ferdig, trykk på "Commit" knappen.

![Commit Message](commit-message.png)

## Inspiser git historikk

Nå er endringene dine lagret i et commit i ditt lokale git repo. Trykk på historikk knappen for å se commit historikken din.

![Open Git History](assets/open-git-history.png)

## Git Push

Trykk på Sync Changes for å pushe endringene dine til GitHub.

![Sync Changes](assets/sync-changes.png)

Gå til forken din i GitHub og se endringene i commit historikken.

## Åpne repo i GitHub

Åpne command palette

![Open Command Palette](assets/open-command-palette.png)

Kjør kommandoen

```
Open In Github: Project
```

## Inspiser historikk i GitHub

I github kan du se commit historikken ved å trykke på commits telleren.

![Open Github Commit History](assets/open-github-commit-history.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Exercises/commit/assets/open-command-palette.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Exercises/commit/assets/open-git-history.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Exercises/commit/assets/source-control.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Exercises/commit/assets/stage-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Exercises/commit/assets/sync-changes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Exercises/commit/assets/sync-fork.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Exercises/commit/commit-message.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- [Oppsett av utviklingsmiljø](Exercises/setup/README.md)
- [Arbeidskrav 1](Exercises/1/Exercises/README.md)
- [Logikk](Exercises/Logic/README.md)
- [Commit](Exercises/commit/README.md)
- [Sync Fork](Exercises/SyncFork/README.md)
- [Functions](Exercises/Functions/README.md)
- [const vs #define](Exercises/ConstVsDefine/README.md)
Expand Down

0 comments on commit ee05ba0

Please sign in to comment.