Version Control/Git

From Wikiversity
Jump to: navigation, search

Git is a distributed revision control software used by many open source projects. This learning resource is meant to help students learn to use it so that they can collaborate with other participants on software projects at Wikiversity.

Readings[edit]

Multimedia[edit]

  1. YouTube: Git Tutorial 1 - How to Download and Install Git
  2. YouTube: Git Tutorial 2 - Config Our Username and Email
  3. YouTube: Git Tutorial 3 - Creating Our First Repository
  4. YouTube: Git Tutorial 4 - Commit
  5. YouTube: Git Tutorial 5 - Adding Files and the Commit Log
  6. YouTube: Git Tutorial 6 - Git Workflow
  7. YouTube: Git Tutorial 7 - How to Edit Files
  8. YouTube: Git Tutorial 8 - Viewing the Changes That You Made
  9. YouTube: Git Tutorial 9 - Comparing the Staging Area with the Repository
  10. YouTube: Git Tutorial 10 - How to Delete Files
  11. YouTube Git Tutorial 11 - How to Move and Rename Files
  12. YouTube: Git Tutorial 17 - Github
  13. YouTube: Git Tutorial 18 - Pushing to a GitHub Repository

Activities[edit]

Git Installation[edit]

  1. Download Git from https://git-scm.com/downloads.
  2. Install Git.

Git Remote Repository[edit]

Copy an existing repository.

  1. Clone a remote repository.
    • Select a local folder to copy the repository into, or create a new folder if you prefer. The repository will be copied as a subdirectory of the selected folder.
    • At a command or terminal prompt, navigate to the selected folder.
    • Clone the repository using the command:
      git clone <url>

Git Local Repository[edit]

Create a local repository.

  1. Initialize a folder for Git.
    • Select a local folder to add to Git, or create a new folder if you are starting a new project.
    • At a command or terminal prompt, navigate to the selected folder.
    • Initialize the folder using the command:
      git init

Make Local Changes and Update Repositories[edit]

Add local changes.

  1. Stage files.
    • Add files to the folder or modify existing files.
    • Add new and modified files to the git staging area using the command:
      git add .
  2. Commit changes.
    • Commit changes into the local repository using the command:
      git commit -m "<some message>"
  3. Connect to a remote repository.
    • Connect to a remote repository using the command:
      git remote add <name> <url>
  4. Push changes to a remote repository.
    • Push changes from your local repository to a remote repository using the command:
      git push

Retrieve Remote Changes[edit]

Retrieve remote changes.

  1. Pull changes from a remote repository.
    • Pull changes from a remote repository to your local repository using the command:
      git pull <name> <branch>

See Also[edit]