@@ -229,6 +229,8 @@ typically you don't need to change this, just hit `Enter`.
229
229
230
230
When done editing you need to exit and return to the command line, you do this with ` Ctrl + x ` .
231
231
232
+ ::::::::::::::::::::::::::::::::::::: callout
233
+
232
234
#### Useful alias
233
235
234
236
You may want to set the following alias in your ` ~/.bashrc ` file, it sets various options. You can then `source
@@ -241,6 +243,8 @@ echo "alias nano='nano --autoindent --linenumbers --tabstospaces --tabsize=4'" >
241
243
242
244
These options will be used whenever you use ` nano ` . See more options with ` nano --help `
243
245
246
+ ::::::::::::::::::::::::::::::::::::::::::::::::
247
+
244
248
## Git Configuration
245
249
246
250
Git configuration comes in two forms, "global" and "local" and is courtesy of some simple text files. The global
@@ -303,7 +307,7 @@ You can always lookup the location of configuration options using the following
303
307
configuration is set as the first column of output.
304
308
305
309
``` bash
306
- git config --list --show-origin --show-scope
310
+ git config --list --show-scope --show-origin
307
311
308
312
```
309
313
@@ -327,16 +331,14 @@ chronological order when you `git branch --list`.
327
331
328
332
## Challenge 1
329
333
330
- Add the fields ` user ` and ` email ` to the ` github ` section of your global configuration setting them to your GitHub
331
- username and your registered email address.
334
+ Set globally the default editor to be ` nano ` (** Hint** this is nested under the ` core ` options).
332
335
333
336
:::::::::::::::::::::::: solution
334
337
335
338
## Solution 1 - Command Line
336
339
337
340
``` bash
338
- git config --global github.user ns-rse
339
- git config --global github.email n.shephard@sheffield.ac.uk
341
+ git config --global core.editor nano
340
342
```
341
343
342
344
:::::::::::::::::::::::::::::::::
@@ -347,9 +349,8 @@ git config --global github.email n.shephard@sheffield.ac.uk
347
349
You could alternatively edit the ` ~/.gitconfig ` file directly and add the following lines
348
350
349
351
``` bash
350
- [github]
351
- user = ns-rse
352
- email = n.shephard@sheffield.ac.uk
352
+ [core]
353
+ editor = nano
353
354
```
354
355
355
356
:::::::::::::::::::::::::::::::::
@@ -376,21 +377,25 @@ As with other configuration options you can also edit the configuration files di
376
377
377
378
::::::::::::::::::::::::::::::::::::: challenge
378
379
379
- ## Challenge 2 - Set a   ; ` git log ` alias
380
+ ## Challenge 2 - Set a   ; ` git log ` & nbsp ; alias
380
381
381
382
` git log ` shows the history of commits on the current branch, but its default is quite verbose. Fortunately there are a
382
383
_ lot_ of options to modify the output adding colour, shortening dates and including a graph and we've been using a
383
384
version a fair bit already. You can see all the options in the manual ([ ` git log --help ` ] [ gitlog ] )
384
385
385
- Rather than having to remember this long complicated command or rely on your shell history you can instead set an alias.
386
+ Rather than having to remember all the options and type them out each time you can set an alias that stores the options
387
+ you want and can be called instead.
386
388
387
- For this exercise add the following set of log options to an alias of your choice (this course uses ` logp ` but you are
388
- free to set it to whatever you want, e.g. ` lp ` )
389
+ For this exercise add the following set of log options to a global alias of your choice (the solution uses ` logp ` but
390
+ you are free to set it to whatever you want, e.g. ` lp ` )
389
391
390
392
``` bash
391
393
log --graph --pretty=format:" %C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short
392
394
```
393
395
396
+ ** NB** - Because there are double-quotes in this command you will if using the command line solution have to enclose all
397
+ of the above in single quotes.
398
+
394
399
:::::::::::::::::::::::: solution
395
400
396
401
## Solution 1 - Edit   ; ` ~/.gitconfig `
0 commit comments