Version Control with Git

Reference

A Better Kind of Backup

  • Use git config to configure a user name, email address, editor, and other preferences once per machine.
  • git init initializes a repository.
  • git status shows the status of a repository.
  • Files can be stored in a project's working directory (which users see), the staging area (where the next commit is being built up) and the local repository (where snapshots are permanently recorded).
  • git add puts files in the staging area.
  • git commit creates a snapshot of the staging area in the local repository.
  • Always write a log message when committing changes.
  • git diff displays differences between revisions.
  • git checkout recovers old versions of files.
  • The .gitignore file tells Git what files to ignore.

Collaborating

  • A local Git repository can be connected to one or more remote repositories.
  • Use the HTTPS protocol to connect to remote repositories until you have learned how to set up SSH.
  • git push copies changes from a local repository to a remote repository.
  • git pull copies changes from a remote repository to a local repository.
  • git clone copies a remote repository to create a local repository with a remote called origin automatically set up.

Conflicts

  • Conflicts occur when two or more people change the same file(s) at the same time.
  • The version control system does not allow people to blindly overwrite each other's changes. Instead, it highlights conflicts so that they can be resolved.

Open Science

  • Open scientific work is more useful and more highly cited than closed.
  • People who incorporate GPL'd software into theirs must make theirs open; most other open licenses do not require this.
  • The Creative Commons family of licenses allow people to mix and match requirements and restrictions on attribution, creation of derivative works, further sharing, and commercialization.
  • People who are not lawyers should not try to write licenses from scratch.
  • Projects can be hosted on university servers, on personal domains, or on public forges.
  • Rules regarding intellectual property and storage of sensitive information apply no matter where code and data are hosted.

Glossary

change set
A group of changes to one or more files that are committed to a version control repository in a single operation.
commit
To record the current state of a set of files (a change set) in a version control repository. If a commit contains changes to multiple files, all of the changes are recorded together.
conflict
A change made by one user of a version control system that is incompatible with changes made by other users. Helping users resolve conflicts is one of version control's major tasks.
HTTP
The Hypertext Transfer Protocol used for sharing web pages and other data on the World Wide Web.
infective license
A license such as the GPL that compels people who incorporate material into their own work to place similar sharing requirements on it.
merge
(a repository): To reconcile two sets of changes to a repository.
protocol
A set of rules that define how one computer communicates with another. Common protocols on the Internet include HTTP and SSH.
remote
A version control repository other than the current one that the current one is somehow connected to or mirroring.
repository
A storage area where a version control system stores old revisions of files and information about who changed what, when.
resolve
To eliminate the conflicts between two or more incompatible changes to a file or set of files being managed by a version control system.
revision
A recorded state of a version control repository.
SSH
The Secure Shell protocol used for secure communication between computers.
timestamp
A record of when a particular event occurred.
version control
A tool for managing changes to a set of files. Each set of changes creates a new revision of the files; the version control system allows users to recover old revisions reliably, and helps manage conflicting changes made by different users.