Version Control/Git

From Wikiversity
Jump to navigation Jump to search
Git logo

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

Copy an existing remote repository[edit]

  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>

Create a local repository[edit]

  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 remote 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 . or git add some_modified_file.txt
  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>

Tips and Tricks[edit]

  • To avoid using --pager in all git log commands, add the following line to your ~/.bash_profile file:[1]
    export GIT_PAGER=cat

See Also[edit]

References[edit]