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
- add a file to the repository (use your favorite text editor)
7
23
- use git status to find out the state of the repository
8
24
- try git status --porcelain
9
25
- What if you didnt like this file, how could you get rid of it (dont do it)
26
+
```bash
27
+
$ git checkout -- filename
28
+
```
10
29
- stage this file change
30
+
```bash
31
+
$ git add filename
32
+
```
11
33
- what do git status, and git status --porcelain show
12
34
- How could you get rid of this file now? Go ahead and fully delete the file.
35
+
```bash
36
+
$ git reset HEAD file
37
+
$ rm file
38
+
```
13
39
- Create a new file, and make sure it gets committed to the repository
14
40
- What remote git repositories does your git repository know about?
41
+
```bash
42
+
$ git remote -v
43
+
```
15
44
- push your new changes to the file up to your github repository
45
+
```bash
46
+
$ git push
47
+
```
16
48
- Find the newly committed file in your github repository. Edit it using
17
49
Github and make a change.
18
50
- Go back to the commandline and use git to pull these changes
51
+
```bash
52
+
$ git pull
53
+
```
19
54
- unix rm the file you created.
55
+
```bash
56
+
$ rm file
57
+
```
20
58
- What do git status and git status --porcelain show?
21
59
- Can you get it back?
60
+
```bash
61
+
$ git checkout -- file
62
+
```
22
63
- rm it again, then stage the removal.
64
+
```bash
65
+
$ rm file
66
+
$ git rm file
67
+
```
23
68
- get it back again
69
+
```bash
70
+
$ git reset HEAD file
71
+
$ git checkout -- file
72
+
```
24
73
- git rm the file. How is this different than using unix rm?
74
+
you can git rm a file, and it will physically remove it and git rm it at
75
+
the same time
76
+
25
77
- Commit the removal of the file, and push the changes up to Github
78
+
```bash
79
+
$ git commit
80
+
```
26
81
- Use the Github Web interface to inspect changes for this file. Can you
27
82
still find the contents of the file in Github? Do you think it is a
28
83
good idea to store usernames and passwords in publicly available GitHub accounts?
84
+
85
+
NO, because GitHub allows you to review the history of your files, where they can
86
+
see the passwords. There are ways to remove them, but it is not easy
87
+
29
88
- See how far you can go with this by changing and staging various file combinations, then changing already staged files, then reverse staged changes, untracked changes of files with staged changes, and fully revert some of the files.
30
89
- Avoiding what git command will ensure that none of these changes ever
31
90
make it into the git log for the repository, or get pushed to a remote
91
+
git commit
32
92
- What if you had committed (without pushes) a bunch of changes to your local fork of the repo, but decided that you didnt like any of it, and would like to get rid of all those commits and revert to the state of the repo as it exists in GitHub. What would be the easiest way to do this?
93
+
```bash
94
+
$ cd ..
95
+
$ rm -rf arangs2015
96
+
$ git clone SSH-CLONE-URL
97
+
```
33
98
- Edit one of the files, but do not add the changes. Create a branch called 'try_bowtie'. Use git status to find out the state of the repo. Add and commit
34
99
your changes to the branch. Use git to find out all the branches you have made (you might see branches pulled in when you forked the repository from someone else). Change to the master branch. Use git status to find out the state of the repository. Can you find your changes? Switch back to the 'try_bowtie' branch. Can you find your changes now? Switch back to the master branch. Merge try_bowtie in to the master branch. Use git status to find the status of the master branch. Commit and push these changes to Github. Use the Github web interface to find out if the branch was pushed. Remove the 'try_bowtie' branch from your repository.
0 commit comments