Version Control/Git



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

 * Git (software)
 * Git
 * Envato Tuts: Easy Version Control with Git
 * How to clone, modify, add, delete Git files

Multimedia

 * 1) YouTube: Introduction to Git
 * 2) Git Tutorial Part 1: What is Version Control?
 * 3) YouTube: Git Tutorial Series (25 videos)

Terms

 * Version control: The act of tracking the changes made by one or more users on a set of files
 * Remote repository: A directory of files tracked by a version control software on a server, usually accessed via the internet
 * Clone: To make a local copy of a remote repository
 * Branch: A set of deviations from a particular state of the repository
 * Merge: The act of combining two branches into a single one
 * Pull: To update a local repository with the latest changes from a remote repository
 * Push: To update a remote repository with the latest changes from a local repository

Git Installation

 * Windows: Download and install Git from https://git-scm.com/downloads.
 * MacOS:
 * Debian-based Linux:
 * Arch-based Linux:

Copy an existing remote repository

 * 1) Clone a remote repository.
 * 2) * 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.
 * 3) * At a command or terminal prompt, navigate to the selected folder.
 * 4) * Clone the repository using the command: . See also:  and

Create a local repository

 * 1) Initialize a folder for Git.
 * 2) * Select a local folder to add to Git, or create a new folder if you are starting a new project.
 * 3) * At a command or terminal prompt, navigate to the selected folder.
 * 4) * Initialize the folder using the command:

Make Local Changes and Update remote Repositories
Add local changes.
 * 1) Stage files.
 * 2) * Add files to the folder or modify existing files.
 * 3) * Add new and modified files to the git staging area using the command: or  or
 * 4) Commit changes.
 * 5) * Commit changes into the local repository using the command:
 * 6) Connect to a remote repository.
 * 7) * Connect to a remote repository using the command:
 * 8) Push changes to a remote repository.
 * 9) * Push changes from your local repository to a remote repository using the command: or  or

Retrieve Remote Changes

 * Pull/get changes from a remote repository to have latest version of the code
 * Pull/get changes from a remote repository to your local repository using the command:
 * or
 * (for more verbose output)
 * (git pull all your repos in parallel, MacOS version)
 * (git pull all your repos in parallel, MacOS version)


 * Pull subdirectories:
 * (assuming all sub-dirs are git repositories)
 * run as if git was started in instead of the current working directory.
 * run as if git was started in instead of the current working directory.

Repository information

 * or  or

Git log

 * Show modifications to a file: or
 * List developers:
 * Show modifications to a file: or
 * List developers:
 * List developers:

Tags / Releases

 * Show all tags in git log:
 * (show releases)
 * List tags with dates: . Just can also add   (note the single-, NOT double-quotes) in the [alias] section of your .gitconfig file.

Miscelaneous

 * Print lines matching a pattern:
 * Print lines matching a pattern:

Tips and Tricks

 * To avoid using  in all   commands, add the following line to your   file:

Activities

 * 1) /Clone some public repositories/
 * 2) Learn what is a merge or pull request: https://stackoverflow.com/questions/23076923/what-is-a-merge-request
 * 3) Create your first website in GitHub/Website Hosting using git
 * 4) Read StackOverflow questions about Git: https://stackoverflow.com/questions/tagged/git?tab=Votes

Wikipedia

 * Git
 * Version control
 * Tig (software)
 * Comparison of source-code-hosting facilities
 * Collaborative development environment
 * Comparison of version-control software
 * Comparison of source-code-hosting facilities
 * List of version-control software
 * TortoiseGit
 * Category:Git (software)
 * Fork and pull model
 * Gitea
 * GitHub
 * Timeline of GitHub
 * Collaborative innovation network
 * Collaborative intelligence
 * Commons-based peer production
 * DevOps
 * GitLab
 * Gitee
 * Magit
 * Virtual File System for Git

External

 * Pro Git – a book written by Scott Chacon and Ben Straub
 * Git Documentation on git-scm.com
 * GitHub: Git Handbook
 * GitHub: Git Tutorial