You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: git-commands.md
+73-10
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,11 @@ vim hello.py
42
42
git add hello.py myname.py
43
43
git status
44
44
git commit -m "Added myname module. Minor modification to hello.py"
45
+
```
46
+
47
+
- Instead of specifying each file in the `git add` line, we can do:
48
+
```
49
+
git add --all
45
50
```
46
51
47
52
7. The `.gitignore` file is special, because it contains the names of the files which should be ignored by Git, like for instance, python `.pyc` files. It is Ok to use wildcards inside it
9. You made a change in `.gitignore`, but then changed your mind and **dropped it**. This instruction changes file back to where it was at last commit
64
+
9. The command `git log` provides, besides the commit messages of the changes, the **_SHA_** ID of every commit. Then, one can use the command `git show SHA` to get a detailed description of the changes related to that commit:
65
+
```
66
+
git show fcf22e5d3cf1c
67
+
```
68
+
69
+
10. You made a change in `.gitignore`, but then changed your mind and **dropped it**. This instruction changes the file back to where it was at last commit
60
70
```
61
71
vim .gitignore
62
72
git checkout -- .gitignore
63
73
```
64
74
65
-
10. You decided to apply and commit other change
75
+
11. You decided to apply and commit other change
66
76
```
67
77
vim .gitignore
68
78
git status
69
79
git add .gitignore
70
80
git commit -m "Modifying .gitignore to exclude all .pyc files"
71
81
```
72
82
73
-
11. Take a look at what is different from our last commit. In this case we want the diff of our most recent commit, and we can refer to it using **_HEAD_**
83
+
12. Take a look at what is different from our last commit. In this case we want the diff of our most recent commit, and we can refer to it using **_HEAD_**
74
84
```
75
85
git diff HEAD
76
86
```
87
+
If what we want to check is whether we are about to commit a file with whitespace errors, let's use:
88
+
```
89
+
git diff --check
90
+
```
77
91
78
-
12. We can unstage files by using the `git reset` command
92
+
13. We can unstage files by using the `git reset` command
'Pulling' can be seen as the combination of two commands: `git fetch`, which fetches down all the changes on the server that we don't have yet, but doesn't modify the working directory, and `git merge`, which combines remote and local data.
215
247
216
-
7. Add a remote repository to push our local repo to the GitHub server (i.e.: We created out repository from scratch and we are setting `origin` in order to be able to _push it_ to a remote server)
248
+
7. Add a remote repository to push our local repo to the GitHub server (i.e.: We created our repository from scratch, and we are setting `origin` in order to be able to _push it_ to a remote server)
0 commit comments