Skip to content

Configure Your Existing Codebase With Git

Hexic Pyth edited this page Mar 8, 2019 · 9 revisions

  1. Backup your source code.

Now, with that out of the way:

  1. Install Git For Windows. Please Select the Following non-default parameters during installation:

    • Git from command-line and also 3rd-party software
    • Use the native Windows Secure-Channel Library
  2. Open VS Code and Click the WPILib button

  3. Create a new VS Code Project

    • Type Create A New Project and strike the Enter key
    • Click Select a Project Type (example or template)
    • Select Template
    • Select Java
    • Select Command Robot Left-Click `Select a New Project Folder'*
    • Navigate to wherever you want your project to be stored. Throughout this example, the project will be stored under C:/Users/user/Desktop/, under a DeepSpace sub-directory.
    • Enter DeepSpace into the Enter Project Name field
    • Enter 3236 in the Team Number field
    • Click Generate Project
      • In this example, this will create the folder C:/Users/user/Desktop/DeepSpace, containing default code for a Java-based Command-Robot.
  4. Delete the existing src directory

    • Click the Start Button and enter Powershell or cmd.exe or [insert name of favorite terminal here]
    • Navigate to the directory you created your new project in. In this example, we will use the following command:
      • cd C:/Users/user/Desktop/DeepSpace
    • Delete the src directory.
      • Windows users will type: del src
  5. Initialize and clone your branch of this repository into the working directory

    • Open your terminal from Step 4 and run the following commands
      • git init
      • git remote add origin https://github.com/FRC3236/DeepSpace.git
      • git fetch
      • git pull origin master --rebase
      • git checkout -t origin/master -b [enter_your_GitHub_username_here]
        • example: `git checkout -t origin/master -b HexicPyth
  6. copy the code you backed up in step 0 to your new branch, the lazy way

    • Assuming your backup was stored at C:/Users/user/Desktop/BackupOfDeepSpace, and your new project directory is C:/Users/user/Desktop/DeepSpace:
      • Using the terminal from Step 4 and Step 5, execute:
        • del src (again)
        • DOS-Style Command-Line Utilities/Syntax is/are stupid, so instead of bothering with them, just use Windows Explorer to copy C:/Users/user/Desktop/BackupOfDeepSpace/src to C:/Users/user/Destop/DeepSpace/src, thus adding the contents of your old src directory to your new src directory
  7. Push your code to your new branch, the lazy way

    • Using your terminal from step 4, step 5, and step 6, type:
      • git add ./src
      • git commit -m "First commit"
      • git push origin [your branch name, see Step 5] -f
        • example: git push origin HexicPyth -f
      • If at any point git tells you to Please tell me who you are:
        • run git config --global user.email [your github email]
        • run git config --global user.name [your name]

8. Oops, there is no step eight. Just open your new project folder in VS Code, and your project is now configured with git. You can pull any newest changes with git pull origin master, and push your changes with the sequence of commands mentioned in Step 7.

Clone this wiki locally