Git
SciencesPo Intro To Programming 2024
11 October, 2024
Question
Objectives
Research team 👇 orders files by YYYYMMDD.
20220629-paper.tex
?20211203-paper.tex
- messed up the file name.git
.Question
Objectives
.git
directory~/houseprices
is endowed with git
version control..git
Danger Zone
Question
Objectives
Note
nano maketable.sh # open nano
# type this:
cd ~/houseprices # make sure we are in the right place
cut -d '|' -f 18 valeursfoncieres-2023.txt | sort | uniq -c | sort -r | head -n 10
# save and exit
git
makes of our additions to this directory.floswald@PTL11077 ~/houseprices (main)> git status
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
valeursfoncieres-2023.txt
maketable.sh
bash
as a shell…git diff
shows you what changed between versions.csv
file.$ git commit -m 'added the maketable script'
[main (root-commit) 9956506] added the maketable script
1 file changed, 2 insertions(+)
create mode 100644 maketable.sh
$ nano maketable.sh
# add this line on top
echo hello user, will make a contigency table now.
# save and exit
$ git diff
diff --git a/maketable.sh b/maketable.sh
index 7e01058..3b7007e 100644
--- a/maketable.sh
+++ b/maketable.sh
@@ -1,2 +1,3 @@
+echo hello user, will make a contigency table now.
cd ~/valeursfoncieres-2023.txt # make sure we are in the right place
cut -d ';' -f 5 valeursfoncieres-2023.txt | tr [:lower:] [:upper:] | sort | uniq -c | sort
README
file.write this in nano and save when done.
git
is like a fotographic camera.Question
Objectives
maketable.sh
script again:HEAD
.HEAD
?maketable.sh
?$ git log --oneline --graph
* a6f023b (HEAD -> main) added readme
* 9956506 added the maketable script
9956506
is the unique identifier of that version.Key Points
git diff
displays differences between commits.git checkout
recovers old versions of files.~/gasprices
~/gasprices
git
tab in Rstudio!if error, create one:
press enter (no passphrase)
check
right, of course Github doesn’t have our public key yet (the lock for our key!)
copy from your terminal
add
a remote by getting the SSH
url from the repository (green button) online.origin
is the name of the remote server. your choice, but origin is common..git
(i.e., the entire history of the repo) on that remote machine.-u
flag sets the main branch as default upstream branch to track.$ git checkout -b testing # checkout repo on new branch `testing`
Switched to a new branch 'testing'
testing
branch.merge
it back into main
if we like it.