or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
2022 UC Carpentries Fall Workshop (Version Control w/ Git)
Workshop Details
Dates: September 6th - 13th, 2022
Time: 9am - 12pm
Workshop Agenda:
https://ucsdlib.github.io/2022-09-06-carpentries-uc/
Day 5: Version Control w/ Git
Software Installation:
Git should be installed on your device from the Day 4 session.
Session lesson-by-Lesson overview and cheatsheet links: https://swcarpentry.github.io/git-novice/reference.html
Workshop Day 5
First name and Last Name/Organization/Dept./Email
NOTES:
A copy of the instructor live session notes will be made available to participants upon request at the end of the workshop.
setup:
Windows users download Git for Windows: https://gitforwindows.org/
Mac/Linux users already have Git installed. Just open the Terminal app
References
Carpentries Git reference guide: Key Points: https://swcarpentry.github.io/git-novice/reference.html
https://education.github.com/git-cheat-sheet-education.pdf
What is Version Control
Tracking files over time. Allowing you to save previous versions and be able to look at them.
Automated Version Control
Version control systems start with a base version of the document and then record changes you make each step of the way.
Git is traditionally done in the Command Line Interface (CLI).
There are a variety of software applications for working in Git. These may be helpful in free version for students of a program called Tower:
Version control is like an unlimited ‘undo’ and allows users to work in parallel.
Setup for Git
git config
Please use your own name and email address instead of Dracula’s. This user name and email will be associated with your subsequent Git activity, which means that any changes pushed to GitHub, BitBucket, GitLab or another Git host server after this lesson will include this information.
We will be using Github for this lesson. You can sign up for a Github account here: https://github.com/
Line Endings
MacOS
Windows
As with other keys, when you hit Enter or ↵ or on Macs, Return on your keyboard, your computer encodes this input as a character.
Read more here: https://www.git-scm.com/book/en/v2/Customizing-Git-Git-Configuration#_core_autocrlf
Find what version of git your computer is using
Default editors
Commands for other editors: https://git-scm.com/book/en/v2/Appendix-C%3A-Git-Commands-Setup-and-Config
Setup your default branch
In 2020, most Git code hosting services transitioned to using the name 'main' to designate the default branch of the repository. However, the Git setup still uses 'master' as the default branch name, so you need to reset it. As an example, any new repository that is opened in GitHub and GitLab default to main. As a result, local repositories must be manually configured have the same main branch name as most cloud services.
Will display your settings in your Terminal window:
Git Help and Manual
Press Q to exit Help screen
Creating a Repository
First, let’s create a new directory in the Desktop folder for our work and then change the current working directory to the newly created one:
Then we tell Git to make planets a repository – a place where Git can store versions of our files:
It will create a git repository in the
planets
directoryGit uses this special subdirectory to store all the information about the project, including the tracked files and sub-directories located within the project’s directory. If we ever delete the .git subdirectory, we will lose the project’s history.
Next, we will change the default branch to be called main. This might be the default branch depending on your settings and version of git.
We can check that everything is set up correctly by asking Git to tell us the status of our project:
Tracking Changes
First let’s make sure we’re still in the right directory. You should be in the planets directory.
Create a text file:
type:
Cold and dry, but everything is my favorite color.
Press CTRL O to save
Hit Enter to confirm save
Press CTRL X to exit nano
We can tell Git to track a file using
git add
:Record changes as a commit:
If we want to know what we’ve done recently, we can ask Git to show us the project’s history using git log:
git log
lists all commits made to a repository in reverse chronological order. The listing for each commit includes the commit’s full identifier (which starts with the same characters as the short identifier printed by the git commit command earlier), the commit’s author, when it was created, and the log message Git was given when the commit was created.Adding to your text file:
Press CTRL O to save
Hit Enter to confirm save
Press CTRL X to exit nano
Check status of your mars.txt file:
Show us the differences between the current state of the file and the most recently saved version:
Adding more lines to your text file:
Press CTRL O to save
Hit Enter to confirm save
Press CTRL X to exit nano
Reverting to the previous change
commiting our changes
and look at the history of what we’ve done so far:
Directories
Remotes in GitHub
Github setup
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/checking-for-existing-ssh-keys
How to check your setup, type into terminal:
ssh -T git@github.com
You should get a message back from github that says "Hi Vlad Dracula" (with your actual name!)
Create a remote repo
log into GitHub: https://github.com/
then click on the icon in the top right corner to create a new repository called
planets
:As soon as the repository is created, GitHub displays a page with a URL and some information on how to configure your local repository:
e.g.: https://github.com/username/planets.git (your link will be slightly different)
Copy that URL from the browser, go into the local planets repository, and run this command:
Pulling changes from remote
Connection issues:
Day 5 Questions:
Please enter any questions not answered during live session here:
1.
End Day 5