<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.cusf.co.uk/index.php?action=history&amp;feed=atom&amp;title=Git</id>
	<title>Git - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cusf.co.uk/index.php?action=history&amp;feed=atom&amp;title=Git"/>
	<link rel="alternate" type="text/html" href="https://wiki.cusf.co.uk/index.php?title=Git&amp;action=history"/>
	<updated>2026-05-30T13:46:36Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.36.1</generator>
	<entry>
		<id>https://wiki.cusf.co.uk/index.php?title=Git&amp;diff=202&amp;oldid=prev</id>
		<title>EllieClifford: Redirected page to Git and GitHub</title>
		<link rel="alternate" type="text/html" href="https://wiki.cusf.co.uk/index.php?title=Git&amp;diff=202&amp;oldid=prev"/>
		<updated>2021-04-23T21:14:38Z</updated>

		<summary type="html">&lt;p&gt;Redirected page to &lt;a href=&quot;/Git_and_GitHub&quot; title=&quot;Git and GitHub&quot;&gt;Git and GitHub&lt;/a&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en-GB&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 21:14, 23 April 2021&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Category:Deleted&lt;/del&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;#REDIRECT &lt;/ins&gt;[[&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Git_and_GitHub&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki-wiki_:diff::1.12:old-201:rev-202 --&gt;
&lt;/table&gt;</summary>
		<author><name>EllieClifford</name></author>
	</entry>
	<entry>
		<id>https://wiki.cusf.co.uk/index.php?title=Git&amp;diff=201&amp;oldid=prev</id>
		<title>EllieClifford: &quot;Fix broken links&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.cusf.co.uk/index.php?title=Git&amp;diff=201&amp;oldid=prev"/>
		<updated>2021-04-23T21:11:32Z</updated>

		<summary type="html">&lt;p&gt;&amp;quot;Fix broken links&amp;quot;&lt;/p&gt;
&lt;a href=&quot;https://wiki.cusf.co.uk/index.php?title=Git&amp;amp;diff=201&amp;amp;oldid=199&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>EllieClifford</name></author>
	</entry>
	<entry>
		<id>https://wiki.cusf.co.uk/index.php?title=Git&amp;diff=199&amp;oldid=prev</id>
		<title>EllieClifford: &quot;Add page on Git&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.cusf.co.uk/index.php?title=Git&amp;diff=199&amp;oldid=prev"/>
		<updated>2021-04-23T20:43:48Z</updated>

		<summary type="html">&lt;p&gt;&amp;quot;Add page on Git&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Git and GitHub =&lt;br /&gt;
&lt;br /&gt;
Git is a distributed version control system used for most software projects&lt;br /&gt;
worldwide. Here at CUSF, we plan to use Git for CAD as well.&lt;br /&gt;
&lt;br /&gt;
GitHub is one of many providers of Git remotes, i.e. a centralized place to&lt;br /&gt;
store Git repositories. It is used by CUSF, you can find our organisation on&lt;br /&gt;
GitHub [https://github.com/cuspaceflight here]&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
=== Linux ===&lt;br /&gt;
&lt;br /&gt;
If you’re using Linux you probably know what you’re doing. If not, just… use&lt;br /&gt;
your package manager…?&lt;br /&gt;
&lt;br /&gt;
=== Windows ===&lt;br /&gt;
&lt;br /&gt;
You may also be interested in downloading the ''Windows Terminal'' from the&lt;br /&gt;
Microsoft Store for a slightly nicer experience.&lt;br /&gt;
&lt;br /&gt;
==== via Git Bash ====&lt;br /&gt;
&lt;br /&gt;
The simplest solution is to use Git Bash, which you can get from&lt;br /&gt;
[https://git-scm.com/download the official download page]. The default options&lt;br /&gt;
are fine. The main drawback is that Git bash does not give you access to the&lt;br /&gt;
Git man pages (manuals).&lt;br /&gt;
&lt;br /&gt;
==== via MSYS2 ====&lt;br /&gt;
&lt;br /&gt;
A more extensible solution is to use [https://www.msys2.org/ MSYS2], which&lt;br /&gt;
gives you access to a native UNIX-like environment. You can then install Git&lt;br /&gt;
(and the man pages, which is highly recommended) from an MSYS2 terminal via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
pacman -S git man-db man-pages-posix&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== via Windows Subsystem for Linux ====&lt;br /&gt;
&lt;br /&gt;
This is not recommended right now, as it is not yet compatible with [[Charon]]&lt;br /&gt;
&lt;br /&gt;
=== MacOS ===&lt;br /&gt;
&lt;br /&gt;
''Adapted from docs written by [https://weixuanz.github.io/ Weixuan Zhang]''&lt;br /&gt;
&lt;br /&gt;
Typically on macOS the package manager to use is [https://brew.sh Homebrew],&lt;br /&gt;
which you can install from a terminal with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
/bin/bash -c &amp;quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then you can install packages via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
brew install git&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
If you encounter a permission error, be cautious when you copy and&lt;br /&gt;
paste solutions from StackOverflow. Make sure you don’t mistakenly give root&lt;br /&gt;
privileges to all files in &amp;lt;code&amp;gt;/usr/local/&amp;lt;/code&amp;gt;.&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
This is not comprehensive, only a quick reference for basic usage. Your first&lt;br /&gt;
port of call if you want to know more should be the man pages (manuals), which&lt;br /&gt;
are accessible via:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git clone https://github.com/username/project&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If in doubt, type &amp;lt;code&amp;gt;git status&amp;lt;/code&amp;gt; into the terminal. It will give you&lt;br /&gt;
some informative output of what is currently going on.&lt;br /&gt;
&lt;br /&gt;
=== UNIX-like terminals ===&lt;br /&gt;
&lt;br /&gt;
'''BEWARE: files deleted on a terminal will not usually go to the recycle bin'''&lt;br /&gt;
&lt;br /&gt;
Refer to&lt;br /&gt;
[https://docs.srcf.net/learn/tutorials/more-terminal.html#more-terminal these]&lt;br /&gt;
docs from the SRCF for a good intro to UNIX-like terminals (i.e. the kind of&lt;br /&gt;
terminal you should be using Git from, see [[Installation]]. Some understanding&lt;br /&gt;
of these terminals is required to use Git. There are graphical clients for Git,&lt;br /&gt;
but usually they should be avoided, as they obscure what's going on (and won't&lt;br /&gt;
work with [[Charon]]).&lt;br /&gt;
&lt;br /&gt;
=== Repositories ===&lt;br /&gt;
&lt;br /&gt;
Repositories are usually self contained projects. They correspond to a&lt;br /&gt;
folder on your computer, and are usually synced to a remote (e.g. GitHub).&lt;br /&gt;
&lt;br /&gt;
To 'clone' an existing repository, i.e. copy the latest version from GitHub:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git clone https://github.com/username/project&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create a local directory &amp;lt;code&amp;gt;project&amp;lt;/code&amp;gt; containing the&lt;br /&gt;
repository.&lt;br /&gt;
&lt;br /&gt;
If you want to create a repository to use with GitHub, it's probably easiest to&lt;br /&gt;
click the plus button on the GitHub website in the top right and let it tell&lt;br /&gt;
you what to do.&lt;br /&gt;
&lt;br /&gt;
If you are creating a repository just locally, the following command will turn&lt;br /&gt;
the current directory into a repository:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git init&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Commits ===&lt;br /&gt;
&lt;br /&gt;
To 'commit' is to make a record of your changes. Except in some special&lt;br /&gt;
circumstances, commits will always exist in the history of the repository, so&lt;br /&gt;
that changes in the project can be tracked and rolled back if necessary.&lt;br /&gt;
&lt;br /&gt;
In order to make a commit, you first need to 'add' changes to Git, which means&lt;br /&gt;
making Git aware of the changes. Having to do this can be useful if you only&lt;br /&gt;
want to commit some of the changes that you have made.&lt;br /&gt;
&lt;br /&gt;
Note that you can use &amp;lt;code&amp;gt;git status&amp;lt;/code&amp;gt; to see what changes have been&lt;br /&gt;
added&lt;br /&gt;
&lt;br /&gt;
To add just the file &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git add file&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add all files in the current directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git add .&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To commit the changes that have been added:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git commit -m &amp;quot;Commit message&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Commit message&amp;quot; should be a short description of what you have changed.&lt;br /&gt;
(Include the quotes)&lt;br /&gt;
&lt;br /&gt;
=== Pushing and Pulling ===&lt;br /&gt;
&lt;br /&gt;
In order to sync your local changes with the remote (e.g. GitHub), you must&lt;br /&gt;
push and pull: pushing uploads your changes to the remote, and pulling gets the&lt;br /&gt;
changes from the remote.&lt;br /&gt;
&lt;br /&gt;
To pull:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git pull&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To push:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git push&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first time that you push, Git does not know which&lt;br /&gt;
[[Git:Usage:Branches|branch]] on the remote to push to, so you instead need to&lt;br /&gt;
use&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git push --set-upstream origin master&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
you can substitute &amp;lt;code&amp;gt;master&amp;lt;/code&amp;gt; with any other branch that you want to&lt;br /&gt;
push to.&lt;br /&gt;
&lt;br /&gt;
=== Branches ===&lt;br /&gt;
&lt;br /&gt;
N.B: Would be nice to add a `git branch --oneline --graph` from something&lt;br /&gt;
complex.&lt;br /&gt;
&lt;br /&gt;
Branches are chains of commits. In a repository, any two branches will have a&lt;br /&gt;
common ancestor, which makes them akin to the branches of a tree.&lt;br /&gt;
&lt;br /&gt;
There is one branch which is the canonical state of the project, usually called&lt;br /&gt;
'master', although alternatives are often used. (In this page, 'master' is&lt;br /&gt;
the name used)&lt;br /&gt;
&lt;br /&gt;
Typically different people will add changes to different branches, and then&lt;br /&gt;
they will be merged together. See [[Git:Pull Requests]]&lt;br /&gt;
&lt;br /&gt;
To create a new branch based on the current branch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git checkout -b branch-name&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To switch branches:&lt;br /&gt;
&lt;br /&gt;
Try to keep the working tree clean when doing this or it will get complicated.&lt;br /&gt;
(i.e. don't have changes which aren't yet part of a commit)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git switch branch-name&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To push a branch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git push origin branch-name&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Pull Requests ===&lt;br /&gt;
&lt;br /&gt;
Pull Requests are a request to include the changes that you have made to your&lt;br /&gt;
branch in the master branch. They are specific to GitHub, alternatives have&lt;br /&gt;
their own way of doing things (which is often very similar).&lt;br /&gt;
&lt;br /&gt;
The easiest way to create a pull request is to go to github.com, navigate to&lt;br /&gt;
the page for your repository, open the branch you want to merge, and click the&lt;br /&gt;
icon to open a pull request.&lt;br /&gt;
&lt;br /&gt;
=== Submodules ===&lt;br /&gt;
&lt;br /&gt;
Submodules are Git repositories inside Git repositories. They can be useful for&lt;br /&gt;
a few reasons:&lt;br /&gt;
&lt;br /&gt;
* Reusing a project in multiple places&lt;br /&gt;
* Using someone else's project as a dependency&lt;br /&gt;
* Segmenting projects into subprojects.&lt;br /&gt;
&lt;br /&gt;
When a submodule exists within a project, it's just a link to another&lt;br /&gt;
repository. Cloning a repository which has submodules will not (by default)&lt;br /&gt;
clone the project's submodules.&lt;br /&gt;
&lt;br /&gt;
To initialise submodules (after cloning the repo):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git submodule update --init&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To add a submodule (&amp;lt;code&amp;gt;location&amp;lt;/code&amp;gt; is optional, it will go to&lt;br /&gt;
&amp;lt;code&amp;gt;repo-name&amp;lt;/code&amp;gt; by default).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git submodule add https://github.com/IDP-L211/repo-name &amp;lt;location&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To update all submodules to the latest commit in their repository&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git submodule update --remote&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To completely remove a submodule (yes it is this annoying)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;g&amp;gt;&lt;br /&gt;
git submodule deinit repo-name&lt;br /&gt;
# now delete the relevant lines in .gitmodules&lt;br /&gt;
rm -rf .git/modules/repo-name&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
As the old adage goes… RTFM. &amp;lt;code&amp;gt;man git&amp;lt;/code&amp;gt; should be your best friend.&lt;br /&gt;
Run it on any terminal where you use Git. It’s much better than any online&lt;br /&gt;
tutorial you will ever find (including this one). There are also manpages for&lt;br /&gt;
each of the Git commands, try &amp;lt;code&amp;gt;man git-add&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;man&lt;br /&gt;
git-commit&amp;lt;/code&amp;gt;, and so on.&lt;br /&gt;
&lt;br /&gt;
The manpages should come first, but do ask someone knowledgeable if you still&lt;br /&gt;
can’t figure it out (or if they’re nice and willing to help).&lt;br /&gt;
&lt;br /&gt;
=== Exiting vim ===&lt;br /&gt;
&lt;br /&gt;
Occasionally Git commands will open vim. Tim's advice is to learn vim, it's&lt;br /&gt;
worth the effort. If you really want to just exit, the following will work&lt;br /&gt;
every time. (there are simpler ways when you know what you’re doing).&lt;br /&gt;
&lt;br /&gt;
Type &amp;amp;lt;ESC&amp;amp;gt;:qa!&amp;amp;lt;Enter&amp;amp;gt;, where &amp;amp;lt;ESC&amp;amp;gt; and &amp;amp;lt;Enter&amp;amp;gt; are the&lt;br /&gt;
escape and enter keys respectively. (You'd be surprised how much clarification&lt;br /&gt;
this usually needs&lt;/div&gt;</summary>
		<author><name>EllieClifford</name></author>
	</entry>
</feed>