User Tools

Site Tools


newdevs:git:install

New Developers Working Group

Git for Windows

If you are running Evergreen on an Ubuntu virtual machine, git should already be installed, but this will allow you to code on a Windows machine without a virtual machine. The git commands will be the same regardless of the environment.

Installation and Configuration

1. Create an SSH Key

The SSH key allows your machine to connect securely to a remote machine, which is required to push (upload) the code you modify to https://git.evergreen-ils.org where all Evergreen code is stored.

  1. Open up a command prompt: cmd
  2. Type ssh-keygen
  3. At the file prompt, enter: C:\Users\your-username\.ssh\id_rsa
    • That path might show up as the default, in which case you can just hit Enter.
  4. You can leave the password blank, or you can enter a password of at least 5 digits for another layer of security.
  5. You should receive a confirmation. Close the command window.
  6. Verify that the .ssh folder and contents have been created.
  7. Email the C:\Users\your-username\.ssh\id_rsa.pub file to gitadmin@evergreen-ils.org and request permission to commit to the Evergreen "working" repository.

2. Install and Configure Git

Git is the software version control system that Evergreen (and many other open source software programs) uses. Git Bash is the Windows program we use on our own computer to track and package changes and interact with the main Evergreen repository. It provides a command-line interface (CLI) - there is also a Windows GUI version, but it doesn't have all of the capabilities of the CLI.

  1. Download and install Git for Windows from: https://git-scm.com/download/win
    • Git Bash will be the program that you use the most, so you may want to add an icon to your desktop or start menu.
    • Choose the option to "Use Git from the Windows Command Prompt" to allow usage of Git from both Git Bash and the command prompt.
    • Choose the option to "Checkout as-is, commit Unix-style line endings" to store your modified files with the correct line ending style.
  2. Verify that Git is installed:
    • Open Git Bash.
    • At the prompt, type "git version" - Git should respond with the version that is installed
    • Set up your user name and password with these commands:
      git config --global user.name "FirstName LastName"
      git config --global user.email "youremail@domain.com"
  3. Add your key
    ssh-add /path/to/your_private_key
  4. If the SSH key you use for this Git repo isn't located at: ~/.ssh/id_rsa then you will need the following configuration file in ~/.ssh/config:
      Host git.evergreen-ils.org
        IdentityFile=<LOCATION OF YOUR SSH KEY>

Navigating Within Git Bash

  • pwd –> This shows you what folder you are currently in.
  • cd –> This returns you to the home directory.
  • cd foldername –> This moves you from the current folder to a child folder.
  • cd .. –> This moves you up in the folder hierarchy one level.
  • ls –> This lists all of the folders and files in the current folder.
  • mkdir newfoldername –> This creates a new folder.
  • Use the keyboard's "up" arrow to scroll through recent commands you've used in order to use them again.

3. Choose a Text Editor (optional)

You can use any text editor you prefer to edit code. Many Evergreen developers use Vim, which runs inside the Git Bash window. You can also use outside programs such as Visual Studio Code, Notepad, Notepad++, or any other text editor that will save flat text. You can configure Git Bash to launch your text editor from a command, or you can use the text editor outside of Git Bash. Notepad++ is used in the instructions here because it will look and act the most familiar to Windows users.

Notepad++
The instructions below are for installing and configuring Notepad++ in the Windows environment so that it can be launched from within Git Bash. As noted above, Notepad++ is just one of the options available.

  1. Download and install Notepad++ from: https://notepad-plus-plus.org
  2. Configure your Windows environment to be able to launch Notepad++ from a command line.
    1. Locate the file path where the Notepad++ executable resides - usually: C:\Program Files (x86)\Notepad++
    2. Open the Windows Environment Variables dialog box. (Depending on your Windows version, you may be able to click Start and then type in 'environment' to open the dialog box and edit the system variables. Otherwise, follow the steps below.)
      • Start > right-click on Computer > choose Properties
      • Click on Advanced System Settings
      • On the Advanced tab, click Environment Variables
    3. In the System variables section, select the Path variable and click Edit.
    4. At the end of the existing Path variable, type a semicolon and then enter the Notepad++ file path (found above). (Or, if paths are shown in a list, add New entry.)
  3. Verify that Git Bash recognizes the new command.
    1. Open Git Bash.
    2. At the prompt, type "notepad++" - this should launch the Notepad++ editor.
    3. Close Notepad++.
  4. Configure Git Bash to use Notepad++ as its default text editor.
    1. Open Git Bash.
    2. Navigate to your home directory (C:\Users\yourname).
    3. To view your current configuration settings, type: cat ~/.gitconfig
    4. To set Notepad++ as your default Git editor, type: git config --global core.editor "notepad++.exe -multiInst -nosession"
    5. To verify, type: git config --global --list
    6. To edit the configuration, type: git config --global -e
    7. Notepad++ should open the configuration file. Verify that your email and name are correct.

Using Notepad++ To launch a document in Notepad++ (whether it is a new document you are creating, or an existing document you wish to view or edit), navigate to the relevant folder, then enter:

notepad++ docname.txt

If you edit the document, save your changes. Then, simply close the Notepad++ window.

4. Clone the Evergreen Repository

Note that these steps assume you have read-only access to origin and write access to working.

  1. Create a folder to store your repositories / branches (for example, C:\Users\yourname\EGProjects).
  2. Open Git Bash.
  3. Navigate to the folder you created above.
  4. Type in: git clone git://git.evergreen-ils.org/Evergreen.git
  5. After the project is cloned, navigate into the new folder: cd Evergreen
  6. Type in: git remote add working git@git.evergreen-ils.org:working/Evergreen.git
  7. Verify that the remote paths are correct: git remote -v
  8. They should be:
origin git://git.evergreen-ils.org/Evergreen.git (fetch)
origin git://git.evergreen-ils.org/Evergreen.git (push)
working git@git.evergreen-ils.org:working/Evergreen.git (fetch)
working git@git.evergreen-ils.org:working/Evergreen.git (push)

If any of these lines are incorrect, correct them by using these commands:

git remote set-url origin git://git.evergreen-ils.org/Evergreen.git
#or
git remote set-url working git@git.evergreen-ils.org:working/Evergreen.git

Alternatively, you can open the configuration file and edit it directly in your text editor of choice:

notepad++ .git/config
newdevs/git/install.txt · Last modified: 2023/12/13 15:03 by tmccanna

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.