English subtitles

← Setting Up Your Workspace on Mac - How to Use Git and GitHub

Get Embed Code
5 Languages

Showing Revision 3 created 05/25/2016 by Udacity Robot.

  1. Now I'm going to walk you
    through the process of
  2. getting your workspace set up on Mac.
  3. And the process on Linux is similar.
  4. There are also written instructions
    in the instructor notes.
  5. If you're using Windows, there
    are instructions in the previous video.
  6. First I'm going to download
    two files that are needed for
  7. the set up I just showed you,
    one to enable tab completion, and
  8. want to enable the special
    Git features in the prompt.
  9. So I'll go to the webpage
    with the first file and
  10. you can find the link to this
    file in the instructor's notes.
  11. Then I'll right-click anywhere
    on the page and select Save As.
  12. And I'll save the file in
    my Downloads directory.
  13. Now I want to make sure that
    Hide extension is unchecked, so
  14. that I can see the exact name
    the file is being given.
  15. And by default,
    it's suggesting Redirecting.txt.
  16. But I want to change this
    to git-completion.bash, and
  17. then I'll Save the file.
  18. Now I want to move the file
    to my home directory,
  19. which I'll do using the Terminal.
  20. Now when I first open the Terminal,
    I start out in my home directory, or
  21. I can type cd ~ to get to
    the home directory if I need to.
  22. Now I'll use the command mv,
    which stands for
  23. move, to move the file I just
    saved into my home directory.
  24. The first argument is
    the file I want to move,
  25. which is in my Downloads directory and
    it's named git-completion.bash.
  26. And I want to move it into the current
    directory while keeping the same name.
  27. Then I'll go through the same process
    to save the second file linked in
  28. the instructor's notes as git-prompt.sh.
  29. Next, I'm going to create
    a file called .bash_profile,
  30. which contains configuration for
    the Terminal.
  31. I recommend using the configuration file
    that I used when filming this course.
  32. To do that, you can download the file
    called bash_profile_course in
  33. the downloadables section.
  34. Next, use the Terminal to move
    this file to your home directory.
  35. You should name it .bash_profile and
    don't forget the dot at the beginning.
  36. Now if you already have a bash profile,
    then don't run this command, and
  37. instead you can copy and
  38. paste the content from this file
    into your existing bash profile.
  39. And if you're running Linux,
  40. then you might need to name this file
    .bashrc instead of .bash_profile.
  41. Now I don't see any changes made to my
    prompt yet, and that's because I'll
  42. need to close and reopen the Terminal
    before the changes take effect.
  43. I'll do that at
    the the end of the video.
  44. In case you're curious about
    what's in this bash profile, or
  45. if you'd like to pick and
  46. choose just the lines you're interested
    in, I'll go through what each line does.
  47. Now, don't worry if you don't
    understand how each line works though.
  48. Even experienced Unix programmers
    frequently copy and paste this kind of
  49. thing from their friends,
    rather than writing it from scratch.
  50. This first line loads one of
    the files you downloaded earlier and
  51. enables tab completion.
  52. These lines define some colors,
    which will be used in your prompt.
  53. This line loads the other
    file you downloaded earlier.
  54. And it's necessary for
  55. the git related stuff like commit
    IDs to show up in your prompt.
  56. This line is what makes sure that
    the asterisk will be shown in your
  57. prompt if you make changes
    in a git repository.
  58. And this line actually defines
    what the prompt will be.
  59. The prompt will show
    your username in purple,
  60. the commit you currently have checked
    out or other git related stuff in green.
  61. And the director URN followed
    by a dollar sign in blue.
  62. Then any text after that will be
    displayed in the default color.
  63. If you're curious to learn more
    about how prompts work in bash,
  64. check out the link in the instructor's
    notes, but it's not necessary for
  65. the rest of this course.
  66. Next, it's important to make sure
    you can launch your favorite text
  67. editor from the Terminal so
  68. that you'll be able to set it as
    your default editor within git.
  69. I'll show how to do this for Sublime.
  70. If you're using another text editor,
  71. I recommend that you Google to figure
    out how to use it from the Terminal.
  72. Now, I can launch Sublime from the
    Terminal by running this long command.
  73. Where this is where Sublime
    is stored on my computer, but
  74. I'd like to have a shortcut.
  75. To create one I'll use Sublime to
    add a line to my bash profile.
  76. Files with a dot at the beginning of
    the name don't usually show up in
  77. file system explorers, so
  78. I'm going to have trouble opening
    my batch profile with Sublime.
  79. To fix this I'll use the trick
    of moving my bash profile
  80. to a file without a dot at
    the beginning of the name.
  81. Then to open the file in Sublime, I'll
    first navigate to my home directory,
  82. which I can do by pressing Cmd+Shift+H.
  83. And then I'll select
    the file bash_profile.
  84. Then I'll add this line to it to
    make the subl command stand for
  85. the same command that you
    saw me enter earlier.
  86. You can copy and
  87. paste this line from the instructor's
    notes if you're using Sublime.
  88. Now I'll save the file and
  89. I'll change the name back to have a dot
    at the beginning using the Terminal.
  90. If I don't do this,
  91. then the bash profile won't take
    effect when I open the Terminal.
  92. Again, this command won't work
    until I've restarted the Terminal.
  93. Now I'll configure git to
    use Sublime as my editor for
  94. things like commit messages.
  95. To do that I'll run git config
    --global core.editor and
  96. here I need to put in double quotes
    the command to open my text editor.
  97. For Sublime that's subl -n -w.
  98. Where -n will open
    Sublime in a new window,
  99. and -w will wait until you close
    your file before continuing.
  100. If you use a different editor,
  101. you will need to modify this part of the
    command to use the editor that you like.
  102. See the instructor's notes for
    more details.
  103. Next I'll run these two
    git config commands,
  104. which will come in handy
    later in the course.
  105. Please copy and
  106. paste these commands from
    the instructor's notes and run them.
  107. Finally I'll close the Terminal and
    reopen it.
  108. Now I can see that my prompt has
    changed to become more colorful.
  109. And if I want to view my
    bash profile using Sublime,
  110. I can run subl .bash_profile.
  111. Remember to close and reopen your
    Terminal when you're finished, or
  112. your changes won't take effect.