diff options
Diffstat (limited to 'web/input/doc/faq/git.md')
-rw-r--r-- | web/input/doc/faq/git.md | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/web/input/doc/faq/git.md b/web/input/doc/faq/git.md index 5503166..390b87a 100644 --- a/web/input/doc/faq/git.md +++ b/web/input/doc/faq/git.md | |||
@@ -43,12 +43,12 @@ repository, and until you want to distribute your change or merge changes from | |||
43 | someone else, everything that follows can happen offline. If you have push | 43 | someone else, everything that follows can happen offline. If you have push |
44 | access to the Nagios Plugins repository, run the command: | 44 | access to the Nagios Plugins repository, run the command: |
45 | 45 | ||
46 | git clone git@github.com:nagios-plugins/nagios-plugins.git | 46 | $ git clone git@github.com:nagios-plugins/nagios-plugins.git |
47 | 47 | ||
48 | If you just want a local copy or wish to clone it to your workstation, you can | 48 | If you just want a local copy or wish to clone it to your workstation, you can |
49 | run this command instead: | 49 | run this command instead: |
50 | 50 | ||
51 | git clone git://github.com/nagios-plugins/nagios-plugins.git | 51 | $ git clone git://github.com/nagios-plugins/nagios-plugins.git |
52 | 52 | ||
53 | This will create a directory called `nagios-plugins` with all the `master` | 53 | This will create a directory called `nagios-plugins` with all the `master` |
54 | code and history (this is roughly equivalent to CVS/SVN `HEAD`). Change | 54 | code and history (this is roughly equivalent to CVS/SVN `HEAD`). Change |
@@ -58,7 +58,7 @@ directory to `nagios-plugins`. | |||
58 | 58 | ||
59 | You can edit the files in the working area. To check the status, use: | 59 | You can edit the files in the working area. To check the status, use: |
60 | 60 | ||
61 | git status | 61 | $ git status |
62 | 62 | ||
63 | This will show a list of changes in the working directory. Newly made changes | 63 | This will show a list of changes in the working directory. Newly made changes |
64 | appear in red, while changes added to the index are shown in green. You can | 64 | appear in red, while changes added to the index are shown in green. You can |
@@ -74,7 +74,7 @@ will add the changes to the index. You can select only partial diffs with | |||
74 | difference between HEAD and the index) with **git diff --staged**, and then | 74 | difference between HEAD and the index) with **git diff --staged**, and then |
75 | commit them with: | 75 | commit them with: |
76 | 76 | ||
77 | git commit | 77 | $ git commit |
78 | 78 | ||
79 | Add a comment (you *have* read the [Development Guidelines][guidelines], | 79 | Add a comment (you *have* read the [Development Guidelines][guidelines], |
80 | right? :-)). This commit will be local (affecting only your own repository), | 80 | right? :-)). This commit will be local (affecting only your own repository), |
@@ -83,7 +83,7 @@ you (in the latter case you will most likely still push to a publicly | |||
83 | accessible clone of your local repository). If the change is from a | 83 | accessible clone of your local repository). If the change is from a |
84 | contributor, set the author at commit time: | 84 | contributor, set the author at commit time: |
85 | 85 | ||
86 | git commit --author="Jane Doe <jane@example.com>" | 86 | $ git commit --author="Jane Doe <jane@example.com>" |
87 | 87 | ||
88 | If you realize that you forgot something in your commit and haven’t pushed it | 88 | If you realize that you forgot something in your commit and haven’t pushed it |
89 | yet to a remote repository, you can amend your last commit with **git commit | 89 | yet to a remote repository, you can amend your last commit with **git commit |
@@ -97,18 +97,18 @@ You can revert local modifications with the following steps. First, if you | |||
97 | have already staged the changes you will have to unstage them. As indicated | 97 | have already staged the changes you will have to unstage them. As indicated |
98 | in the **git status** message you can do so with the following command: | 98 | in the **git status** message you can do so with the following command: |
99 | 99 | ||
100 | git reset HEAD <file> | 100 | $ git reset HEAD <file> |
101 | 101 | ||
102 | Then you can revert unstaged changes with: | 102 | Then you can revert unstaged changes with: |
103 | 103 | ||
104 | git checkout <file> | 104 | $ git checkout <file> |
105 | 105 | ||
106 | If you have already committed changes locally and need to undo your commit(s), | 106 | If you have already committed changes locally and need to undo your commit(s), |
107 | you can use **git reset**. First find the commit names with **git log** and | 107 | you can use **git reset**. First find the commit names with **git log** and |
108 | then do either one of these: To keep local modifications (you can commit them | 108 | then do either one of these: To keep local modifications (you can commit them |
109 | again, stash them, etc.) | 109 | again, stash them, etc.) |
110 | 110 | ||
111 | git reset --soft <commit> | 111 | $ git reset --soft <commit> |
112 | 112 | ||
113 | Note that for the purpose of “re-doing” the last commit, **git commit | 113 | Note that for the purpose of “re-doing” the last commit, **git commit |
114 | --amend** will be much easier than a reset/commit with the same end result. | 114 | --amend** will be much easier than a reset/commit with the same end result. |
@@ -116,7 +116,7 @@ To discard local modifications (if you lose important changes with this | |||
116 | command you may be able to recover them with **git reflog** and **git checkout | 116 | command you may be able to recover them with **git reflog** and **git checkout |
117 | <commit\>**): | 117 | <commit\>**): |
118 | 118 | ||
119 | git reset --hard <file> | 119 | $ git reset --hard <file> |
120 | 120 | ||
121 | Do not reset changes that have already been pushed to remote repositories as | 121 | Do not reset changes that have already been pushed to remote repositories as |
122 | this will cause non-linear updates. If you do so, all developers using those | 122 | this will cause non-linear updates. If you do so, all developers using those |
@@ -131,14 +131,14 @@ If you do, either commit them or put them aside (hint: **git stash**). If you | |||
131 | cloned from the main Git repository, this command will do a fetch and then | 131 | cloned from the main Git repository, this command will do a fetch and then |
132 | merge any new changes: | 132 | merge any new changes: |
133 | 133 | ||
134 | git pull | 134 | $ git pull |
135 | 135 | ||
136 | You can also merge changes from any other fork of the repository. This | 136 | You can also merge changes from any other fork of the repository. This |
137 | usually happens if someone asks you to pull from his own repo for some fix or | 137 | usually happens if someone asks you to pull from his own repo for some fix or |
138 | enhancements. Together with **--no-commit**, you will have a chance to review | 138 | enhancements. Together with **--no-commit**, you will have a chance to review |
139 | the changes and make any relevant correction before the merge. Example: | 139 | the changes and make any relevant correction before the merge. Example: |
140 | 140 | ||
141 | git pull --no-commit git://example.com/path/to/repo.git master | 141 | $ git pull --no-commit git://example.com/path/to/repo.git master |
142 | 142 | ||
143 | ## Merging Back to the Main Repository | 143 | ## Merging Back to the Main Repository |
144 | 144 | ||
@@ -146,7 +146,7 @@ Once you’re done with your commits, and after pulling from the main | |||
146 | repository, you can push your changes back to it. If you cloned using the | 146 | repository, you can push your changes back to it. If you cloned using the |
147 | *push* URL, this command will push the master branch: | 147 | *push* URL, this command will push the master branch: |
148 | 148 | ||
149 | git push | 149 | $ git push |
150 | 150 | ||
151 | It you’re trying to push something that would generate merge conflicts, the | 151 | It you’re trying to push something that would generate merge conflicts, the |
152 | push will be rejected. You will have to do a pull first, fix any conflicts | 152 | push will be rejected. You will have to do a pull first, fix any conflicts |
@@ -154,7 +154,7 @@ locally, and then push again. If your commits are local (you haven’t pulled | |||
154 | them from someone else or published them somewhere) you can rebase to avoid a | 154 | them from someone else or published them somewhere) you can rebase to avoid a |
155 | merge: | 155 | merge: |
156 | 156 | ||
157 | git pull --rebase | 157 | $ git pull --rebase |
158 | 158 | ||
159 | Like a merge, this may generate conflicts and let you fix them, but instead of | 159 | Like a merge, this may generate conflicts and let you fix them, but instead of |
160 | creating a merge commit on top of the others, it will undo your commits, | 160 | creating a merge commit on top of the others, it will undo your commits, |