Connected Lab 1

Installing Git

This lab will guide you through the steps for installing Git on your system. If you already have Git installed, you can skip to the next chapter. Otherwise, select the appropriate section for your operating system, and follow the instructions.

Installing Git for Windows

The Git for Windows package installs a version of Git that also includes a Bash (Unix) shell that runs on top of Windows and provides a Unix-style interface to Git. You can also integrate Git with the Windows Explorer and command prompts.

The following instructions provide the necessary steps for installation, as well as additional information on the install screens you will encounter during the process.

Steps

Each of the following numbered steps represents a new screen of the installation tool.

  1. In your browser, go to http://git-scm.com/download/win. The download starts automatically.
  2. After the download completes, double-click the executable file (or select the “Run” button if one is available) to start the install (If any security prompts come up, answer them to allow the install to run.)
  3. Click Next after viewing the license agreement.
  4. (Optional) Deselect any integration pieces you don't want. This allows you to set up integration with the Windows Explorer and file associations if you want. Click Next.
  5. Select how you want to use Git. This screen gives you several options:
    1. a. Use Git from Git Bash only: This refers to the Unix shell that comes as a separate program with Git for Windows. If you are comfortable with Unix, or you aren't and don't intend to run many operating system commands, this is the simplest option. The shell features some nice color-coding that can be helpful as you're learning Git. This option won't allow you to use Git integration in Windows command prompts.
    2. b. Use Git from the Windows Command Prompt: The main purpose of this option is to allow you to run Git commands in Windows command prompts. It also includes the ability to use Git through the Git Bash shell. It does not try to provide full integration with some of the Unix applications in command prompts as the first option does. This is a good default because it provides the flexibility to use Git in either or both the Bash shell and Windows command prompts.
    3. c. Use Git and optional Unix tools from the Windows Command Prompt: This option provides some additional Unix-style tools for you to use from command prompts. Keep in mind that these tools will be in the path and found before some of the Windows commands of the same name. In general, if you want to use Unix commands and tools, you're better off doing so through the Bash shell interface.
  6. If you have access to Plink (PuTTy link) on your system, you see an additional screen allowing you to choose which SSH executable you want to use here. Unless you have a specific reason to do otherwise, choosing the Use OpenSSH option is fine.
  7. Configure the line ending conversions. This refers to how you want Git to handle line endings in files when getting content out of Git or putting content into Git. I cover this setting in detail in Chapter 4. You can jump ahead and read about that now if you want, but briefly, this relates to how you plan to edit files you'll be managing with Git. You can find more details on the different options in the following paragraphs.

    If you plan to use Windows editors, then the first setting—Checkout Windows-style, commit Unix-style—will probably work best. This setting means that when you get text content out of Git, Git updates the line endings in the checked-out files to be carriage-return/line-feed (CRLF). This is the line ending expected by Windows editors. When you check in (or commit) content back into Git, Git strips out the CRs and stores (normalizes) the text/ASCII files with line endings that are just LF (the default for Unix).

    On the other hand, if you plan to edit with Unix-based editors (vi or others) or work primarily through the Bash shell, then the Checkout as-is, commit Unix-style line endings setting may be the best choice. This doesn't make any changes to the files on checkout, but normalizes them to LFs when storing them in Git. So, essentially, they will always have LFs. Because LF-only is the default for Unix systems, this works well for editing in that environment.

    The last choice—Checkout as-is, commit as-is—can be problematic. Basically, this tells Git not to make any changes for line endings—just to leave them as they are. This means that you can end up with a mixture of line endings in the repository. The other two options normalize files in the repositories to LFs. If a file is edited in a Windows editor and then stored back in Git, the file stored in the Git repository will contain CRLFs. However, if edits are done in Unix editors, the files will have just LFs stored in the repository. If someone then gets one of these files out on an OS that is different from the OS where it was last edited, they may be surprised by the line endings being in the style of the other OS. This can be especially troublesome for teams where some members use Unix and other members use Windows.

    You can change this setting at a later time by changing the configuration value for core.autocrlf that is mentioned here. (I cover this in more detail in Chapter 4.) However, at that point, there may already be files stored in the repository with undesired line endings. There are ways to fix these files that are beyond the scope of this discussion.

    For most of the work you'll do in the Connected Labs for this book, the value of this setting won't be significant. However, the best practice here is to choose one of the first two settings that best corresponds to the OS type where you plan to run your editors.

  8.  Configure the terminal emulator for the Bash shell. You have a choice of which terminal program you want to use for the Bash shell. Unless you have a specific reason to choose the Windows default console window option, choose the Use MinTTY option. This gives you a better user interface that supports functions such as Copy and Paste in the expected way (highlight and select) rather than with the limited functionality of the console window option.
  9.  Configure extra options. The Enable file system caching option is a relatively new addition. It attempts to speed up file-related operations for users of Git on Windows, where the file handling is not optimized in the same way as it is for Unix. In principle, this seems like a good option, although most users have had limited experience with it. Note that it can be turned off later by changing the core.fscache configuration value. This is one option you should probably turn on until any issues are found with it.

    The Git Credential Manager for Windows is a successor to a previous credential management application. It essentially helps with managing and simplifying different types of access for Git from various applications. Its use is generally transparent to the user. You can read more about this application in the README file for the project on the GitHub hosting site at https://github.com/Microsoft/Git-Credential-Manager-for-Windows/blob/master/README.md.

    Unless you have a specific reason not to use this application, just leave it checked.

  10.  Once you've completed the option screens in these steps, click the Install button. Git removes any old installs (if they exist) and updates with the newest version. Afterward, you have a new Git category in your available programs list with entries to start the Git Bash shell (the Unix shell), a Git CMD window, and a GIT GUI interface.

    The Git CMD window is like a Windows command prompt. However, you can start up a Windows command prompt and also have access to Git in this window.

  11.  Open the Git Bash shell, the Git CMD window, or a Windows command prompt, and type
    $ git --version

    to make sure you have Git installed and are running at the expected version.

Installing Git on Mac OS X

  1. In your browser, go to http://git-scm.com/download/mac. The download starts automatically. If not, there is a link you can click to start it.
  2. Install the downloaded file via the DMG and PKG files.
  3. Open up a terminal, and run the following command to make sure Git is installed and running at the expected version:
$ git --version

Installing Git on Linux

  1. In your browser, go to http://git-scm.com/download/linux.
  2. Follow the instructions on that page for the particular flavor of Linux you're using.
  3. Confirm that Git is installed by opening up a terminal session and running the following command:
$ git --version
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset