-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
the-only-5-git-commands-you-need-to-know.scroll
92 lines (62 loc) · 2.64 KB
/
the-only-5-git-commands-you-need-to-know.scroll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
date 2010-0-23
tags index
permalink the-only-5-git-commands-you-need-to-know.html
title The only 5 git commands you need to know
pageHeader.scroll
chat
What's the difference between a great programmer with great social skills and a great programmer who does not use version control?
Nothing--they both don't exist!
If *every single great programmer* uses version control, why do some beginning programmers avoid it?
Because version control is made to seem intimidating. But version control is actually very easy!
If you are new to version control, there are only 5 commands you need to memorize. Can you memorize 5 words? Of course you can.
So memorize these 5 words and you'll be practically an expert at version control:
code
init
add
status
commit
push
If you just start playing around with these 5 and only these 5 commands, you'll become a git master in no time.
Here's a simple practice session you can follow to start getting good.
? What is git?
Git is a simple command line program like "wget" or "vim" that you install and use by typing commands. If you don't have git installed, try one of these commands:
code
yum install git-core
apt-get install git-core
sudo port install git-core
Let's say you're creating a new website for your mom and want to use version control to do it.
code
mkdir moms_website
cd moms_website
git init
This creates a git repository. Now type:
code
ls -a
Do you see the new ".git" directory? That's the git repository. It's basically a folder that stores the whole history of your project. Now, when you type a git command, it will do something with the files in that folder. That's all that's really going on. You never need to go into that folder manually, I was just explaining what git is doing.
Now, let's create a file and add it to your repository.
code
vim index.php
Hello World
:wq
git status
This will show the presence of an untracked file, "index.php". Let's add this file.
code
git add index.php
You've now added the file to git, let's *commit* our changes.
code
git commit -m "first commit"
Now you've made your first commit.
The last command you'll need is *push*. It works like this:
code
git push
That will upload your repository to an online host like github so that other people can collaborate.
Create a github account and follow the instructions for creating a new repository to test out this final command.
That's it! Those are the 5 commands you'll use over and over again. Master those and slowly you'll start learning a few other helpful git commands.
# Recap
code
git init
git status
git add *filename*
git commit -m *"your message about what you changed and why"*
git push
footer.scroll