This writuep provides a minimal introduction and assumes you
nano
, vi
, or emacs
ssh
.
as meaning the current directory
..
as meaning the directory containing the current directory
~
as meaning my home directory
An introduction to using git
for version control can be found in our other git writeup
untrackedor
modified
untrackedfile has no copy in the git-managed space
modifiedfile has been changed from the last git-managed version
addinga file tells git to care about your changes to it
committinga file tells git top update the git-manages copy to match your version. You can only commit added files.
push, saying
remote computer, you should know about what I’ve done lately.
pull, saying
remote computer, what have you done lately?
user.name
and user.email
Git is designed for collaboration, so it does not allow anonymous contributions. Hence, you have to tell it a name and email, either once per project or once for all projects on your computer. This information is visible only to other people who have access to your git project.
While inside the git project directory created by git clone
, run the following commands, using your name and email ID instead of those in the example:
From anywhere, run the following commands, using your name and email ID instead of those in the example:
Git will complain if you try to git commit
without having done this.
We assume you are at UVA in a course that has given you SSH-access to portal.cs.virginia.edu
.
Create the git-managed project on the server, portal.cs.virginia.edu
. Use your user name, not mst3k
, and any name you want (we assume coa1-code
but you can change that)
SSH into the server and run
Create a working copy of that project on the server
SSH into the server and run
Create your local working copy of that project
On your own machine run
We expect the most common case will be you’ve created or modified a file on your laptop and want to try running it on the server. Let’s go through this step by step, assuming you start in Terminal/PowerShell in the directory of your project on your laptop
git add file1 file2 ...
Tell git
which files you want to have sent. If you want everything in the current directory sent, you can use git add .
.
If you created no new files, you can skip this step as described below.
git commit -m "I changed a few files"
Tell git
to update it’s internal copy of the files you’ve added and label this change I changed a few files
. Using good descriptive labels becomes more important as project teams grow.
You can add and commit in one step if you have only modified (not added) files by using git commit -a -m "fixed typos"
git pull
git pull
before git push
.
git push
git
to send your changes to the master repository on the remote server
ssh mst3k@portal.cs.virginia.edu
cd myclass-code
git pull
If you edit the code on the server, make sure you also add/commit/pull/push on the server and pull on your laptop before you edit them on the laptop as well.
There are many GIT tutorials. A few I’ve heard people say nice things about include: