essential_commands.md 1.63 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# The 5 essential commands


**Yes**, you only need 5 commands!

`pull, status, add, commit, push`

or in other words (remember these!):
```bash
$ git pull <remote> <branch>
$ git status
$ git add myFile.md # example
$ git commit -m "myMessage" # example
$ git push <remote> <branch>
```



19

20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Pull the latest version of an existing branch

Pull the latest revision on branch `myBranch`:
```bash
$ git pull origin myBranch
# Already up to date
```

<div class="fragment">

Verify its `status` with:
```bash
$ git status
```

35
36


37
38
# Modify a file

Laurent Heirendt's avatar
Laurent Heirendt committed
39
Copy the file `firstnameLastname.md` in the folder `_attendees` and rename it with your firstname:
40
41

```bash
Laurent Heirendt's avatar
Laurent Heirendt committed
42
$ cd _attendees
43
44
45
46
47
$ cp firstnameLastname.md myName.md
```

Then, make your changes with your favorite editor!

Laurent Heirendt's avatar
Laurent Heirendt committed
48
49
50
<br><br>
Reference for markdown: https://howto.lcsb.uni.lu/?contribute:markdown

51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102


# Add your file to the stage

First, check the repository status
```bash
$ git status
# uncommitted changes (displayed in red)
```


<div class="fragment">

Now, add the file (bring it on stage)
```bash
$ git add myName.md # replace myName
$ git status
# returns the same as before, generally in green (means staged)
```

<div class="fragment">

**ADVANCED**: If there have been more changes after the file has been added, you can see your changes in the terminal
```bash
$ git diff
```
exit with `q`



# Add a commit message

```bash
$ git commit -m "Add the profile of <myName>"
$ git status
```



# Push your file to your fork

```bash
$ git push origin myBranch
```

<div class="fragment">

**ADVANCED**: see the log of all the commits (and your last one) in the terminal
```bash
$ git log
```
exit by typing `q`.