Digital Education Resources - Vanderbilt Libraries Digital Lab
Previous lesson: setup
In this lesson, you will go through a complete work cycle. You will control when things are staged, committed, and pushed to GitHub using the controls in GitHub Desktop. You will learn about the difference between raw and rendered views of documents. You will also see how versions have changed between commits by examining a diff.
Learning objectives At the end of this lesson, the learner will be able to:
Open the repository in your external editor
option in GitHub Desktop..xlsx
format)..gitignore
file so that file type will not be suggested for staging.Total video time (including optional videos): 49 m 44 s
Total video time (required videos only): 31 m 57 s
. Pulling changes
When you are editing files using GitHub desktop, it is important to have a disciplined work cycle to make sure that your work gets saved to the hub without merge conflicts.
After you’ve decided what branch you need to work on, it’s very important to make sure at the start that you are working on the most recent version of it by pulling any changes from Github. Click on the Fetch origin button at the upper right of the window. If there are changes that need to be downloaded, you’ll see a small number by a downward pointing arrow. Click the button (now labeled “Pull origin”) again to download those changes.
If you forget to update your local copy of the branch, you risk creating a conflict, since you may be working on a copy that isn’t the most recent one.
Editing and committing
To make an edit, navigate to the directory where you checked out the repo. Open a file, make some edits, then save the file.
If you click on the Changes tab at the upper left of the GitHub Desktop window, you should see the files that changed since the last update and clicking on a filename will show the kind of changes at the right of the screen (additions in red, deletions in green).
Commit your changes. You’ll then see the new commit in the history and as a change that’s ready to push up to GitHub.
Click on the Push origin
button to push your changes from the desktop client to GitHub.
This video provides a more detailed look at what we saw in the last video.
This video provides important information about what CSV files are and how they differ from Excel spreadsheets. It explains why Excel is not the preferred editor for editing CSV files. If you are using CSV files in coding, I recommend using Libre Office to edit them. Unlike Open Office it does not put a file lock on a file that is currently being edited. A file lock can crash a script if you forget that you have the CSV open in the application.
.
Kinds of files that work well with GitHub version control
Although you can use GitHub for version control on any type of file, the features of GitHub were designed with maintenance of text files in mind. If you are editing a simple text file, there is no particularly compelling reason why you can’t just do the editing in the browser using the built-in GitHub editor. However, if you are editing a file that contains markup, such as Markdown or XML, or if you are editing code, it is probably easier to do the editing on your desktop using dedicated editing software. Examples are Oxygen for XML and Visual Studio Code (not actually part of Microsoft Visual Studio) for editing many kinds of code. For working with GitHub, there are some advantages to using the Atom editor https://atom.io/. Atom was developed by the GitHub team and has some useful features for working directly with GitHub. There are a lot of plugins available for Atom that do syntax highlighting for different coding languages, and Atom also has a useful Markdown preview feature (available from the Packages menu).
GitHub works reasonably well for some other types of files like CSV spreadsheets and Jupyter notebooks. When editing these files, you’ll want to use an editor designed specifically for them, such as Open Office or Libre Office for CSV, or Anaconda/Jupyter for Jupyter notebooks. When you look at the raw text of these files, they will be a bit difficult to comprehend, but when they are pushed to GitHub, it is pretty good at displaying them so that they look the way they did in your software (i.e. as a table or notebook).
GitHub does NOT work well for managing documents written with proprietary software like Microsoft Word or Excel, at least when files created in those applications are saved in their native file formats (.docx
and .xlsx
). You can commit and upload the files, but GitHub can’t display them and they will be impossible to comprehend in the desktop client preview or on GitHub itself.
.
Checkboxes are used to control which files are staged for the next commit.
Download
button will be a Raw
button. In that case, if you want to download the deleted file, right click on the Raw
button and select Save Link As...
or something similar depending on your browser.Changes
tab to make sure that you don’t have any edits that should be committed and pushed before you quit.Next lesson: recovering from disasters
Revised 2022-01-24
Questions? Contact us
License: CC BY 4.0.
Credit: "Vanderbilt Libraries Digital Lab - www.library.vanderbilt.edu"