Version Control
Whether developing, porting or maintaining a source code project, using a formal source code management practice will allow you to easily revert changes, merge work from other people or simply recover from mistakes or disasters. This practice is often termed revision control or version control.Though version control costs some time, the long term benefits far outweigh the short-term costs, especially as projects become larger and more complex.
Git
Git is one of the most popular source code management systems available and it is extensively used at Pawsey. It is best known for hosting the Linux kernel. It allows the user to track and manage updates to a repository (such as new files), and create branches to group and isolate changes for later merging. Git is available on Pawsey systems.
Git can be run from the command line. The most common CLI commands are:
git clone <git-repo-name> | Clone a (remote) repository to a local directory. |
git status | Check the current status of the repository, showing modified files and untracked files. |
| Check out a branch named branch-name. Create and check out a branch named branch-name. |
git add <new or modified files> | Add modifications to existing tracked files or add new files to be tracked. |
git commit | Commit a set of changes that have been added to the git history through the git add command. |
git push | Push local commits to the remote repository, allowing other users to see changes. |
git merge | Merge changes from one branch into another branch. |
$ git clone https://github.com/PawseySC/Introductory-Supercomputing $ cd Introductory-Supercomputing $ git status On branch master Your branch is up to date with 'origin/master'. nothing to commit, working tree clean $ git log commit bdfb1da173fe597096439faaa8709ccb5d09aab7 (HEAD -> master, origin/master, origin/HEAD) Author: CDP <coder@example.com> Date: Mon Nov 22 10:54:15 2021 +0800 Adds gpu example. $ git checkout -b temp Switched to a new branch 'temp' $ touch foo.txt # create a file foo.txt $ git add foo.txt # track file $ git commit -m "Adding new file" # commit changes with message "Adding new file" [new-branch b49e42b] Adding new file 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 foo.txt $ git checkout master # checkout out master branch $ git merge temp # merge temp branch with master Updating bdfb1da..b49e42b Fast-forward foo.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 foo.txt
Git learning resources and downloads
To learn more about git:
- Read the free online Pro Git book
- Follow the dedicated Version Control with Git course, delivered by Software Carpentry.
There are a variety of Git GUIs, including:
These and a range of other clients can be downloaded from:
Subversion
Subversion (svn
) was one of the most popular source code management systems for many years. Although it is currently less popular than Git, it is still being used by a number of development groups.
To learn more about Subversion read the free online book: http://svnbook.red-bean.com/.