.txt, .csv, .py,
.c, .R, etc.) works best
| Sourcetree | Git Kraken | Git Desktop |
|---|---|---|
|
|
|
| PyCharm | RStudio | VS Code |
|---|---|---|
|
|
|
git config --global user.name "Me"git config --global user.email "me@email.com"git config --global core.editor "nano -w"git config --listuser.name=Sam Mangham user.email=mangham@gmail.com core.editor=nano -w [plus much more on Windows]
ssh-keygen -t ed25519cat ~/.ssh/id_ed25519.pubGenerating public/private ed25519 key pair. Enter file in which to save the key (/c/Users/Toaster/.ssh/id_ed25519): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/Toaster/.ssh/id_ed25519 Your public key has been saved in /c/Users/Toaster/.ssh/id_ed25519.pub The key fingerprint is: SHA256:<a long string> Toaster@Toast-Nova The key's randomart image is: <a square 'picture'>
ssh-keygenclimate-analysisgit clone git@github.com:yourname/climate-analysiscd climate-analysisls -agit statusgit clone <your repo>Cloning into 'climate-analysis'... remote: Enumerating objects: 4, done. remote: Counting objects: 100% (4/4), done. remote: Compressing objects: 100% (4/4), done. remote: Total 4 (delta 0), reused 3 (delta 0), pack-reused 0 (from 0) Receiving objects: 100% (4/4), done.
git status# On branch main nothing to commit, working tree clean
:)cd to enter climate-analysisnano README.mdCtrl-O then Enter to save,
Ctrl-X to quitgit add README.mdgit statusgit commit -m "Your message"git statusgit add README.mdIf you’re on Windows, you might see:
warning: in the working copy of 'README.md', LF will be replaced by CRLF the next time Git touches it
git commit -m "Your message"[main 3347109] Added a basic readme file 1 file changed, 4 insertions(+) create mode 100644 README.md
git statusOn branch main Your branch is ahead of 'origin/main' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working directory clean
nano (Ctrl-O to save,
Ctrl-X to quit)git add README.md-m on commit (write your message in
nano)git loggit logcommit 334710937654821b3a89996c2c6af476548d28e9 (HEAD -> main) Author: Sam Mangham <mangham@gmail.com> Date: Wed Jan 8 18:40:04 2025 +0000 Added a basic readme file commit 3f6b071ef0d35af70793954adb00a3fc7fc7b949 (origin/main, origin/HEAD) Author: Sam Mangham <mangham@gmail.com> Date: Wed Jan 8 18:35:45 2025 +0000 Initial commit
nano climate_analysis.pygit diffgit add climate_analysis.pygit commit -m "Your message"git diffdiff --git a/climate_analysis.py b/climate_analysis.py index 277d6c7..347c42b 100644 --- a/climate_analysis.py +++ b/climate_analysis.py @@ -1,3 +1,5 @@ +"""Tools for analysing climate data files""" + import sys import temp_conversion import signal
git commit[main 0010185] Add docstring 1 file changed, 2 insertions(+)
nano to edit climate_analysis.py# TODO: Add rainfall processing code” to the
endnano climate_analysis.pygit diffgit add climate_analysis.pygit commit -m "Your message"git loggit diff HEAD~1 climate_analysis.pygit diff HEAD~2 climate_analysis.pygit logcommit ed664c6d480f93829608791f3d8158f2dcab4107 (HEAD -> main) Author: Sam Mangham <mangham@gmail.com> Date: Thu Jan 9 10:11:27 2025 +0000 Added rainfall processing placeholder [3 more commits]
git diff HEAD~1 climate_analysis.pydiff --git a/climate_analysis.py b/climate_analysis.py index 347c42b..ce8ef32 100644 --- a/climate_analysis.py +++ b/climate_analysis.py @@ -27,3 +27,6 @@ for line in climate_data: kelvin = temp_conversion.fahr_to_kelvin(fahr) print(str(celsius)+", "+str(kelvin)) + +# TODO: Add rainfall processing code +
climate_analysis.py
since thengit loggit diff <COMMIT ID> climate_analysis.pyrm climate_analysis.pygit statusgit restore climate_analysis.pyrestore doesn’t work, try
checkoutgit statusOn branch main Your branch is ahead of 'origin/main' by 3 commits. (use "git push" to publish your local commits) Changes not staged for commit: (use "git add/rm <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory) deleted: climate_analysis.py no changes added to commit (use "git add" and/or "git commit -a")
git checkout <COMMIT ID> climate_analysis.pygit pushgit pushCounting objects: 11, done. Delta compression using up to 32 threads. Compressing objects: 100% (9/9), done. Writing objects: 100% (9/9), 1.11 KiB | 0 bytes/s, done. Total 9 (delta 2), reused 0 (delta 0) remote: Resolving deltas: 100% (2/2), completed with 1 local object. To git@github.com:smangham/climate-analysis 70bf8f3..501e88f main -> main
https rather than sshLocal:
nano README.mdgit commit -am "Your message"Remote:
README.md to add install info to the endmaingit pushgit pushTo git@github.com:smangham/climate-analysis ! [rejected] main -> main (fetch first) error: failed to push some refs to 'git@github.com:smangham/climate-analysis' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first merge the remote changes (e.g., hint: 'git pull') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
main
branches?git pullgit config pull.rebase false if it failsnano README.md and remove the
<<</===/>>>git add README.mdgit commit -am "Your message"git pushgit pullremote: Enumerating objects: 5, done. remote: Counting objects: 100% (5/5), done. remote: Compressing objects: 100% (3/3), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. From github.com:smangham/climate-analysis 501e88f..023f8f6 main -> origin/main Auto-merging README.md CONFLICT (content): Merge conflict in README.md Automatic merge failed; fix conflicts and then commit the result.
git branchgit branch devgit switch devswitch doesn’t work, try
checkoutgit switch devSwitched to branch `dev`
git switch dev doesn’t work, try
git checkout devnano rainfall_conversion.pygit add rainfall_conversion.pygit commit -m "Your message"lsgit loggit switch mainlsgit loggit switch devgit push origin devgit config --global push.autoSetupRemote truegit push origin devEnumerating objects: 25, done. Counting objects: 100% (25/25), done. Delta compression using up to 20 threads Compressing objects: 100% (25/25), done. Writing objects: 100% (25/25), 4.40 KiB | 2.20 MiB/s, done. Total 25 (delta 6), reused 3 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (6/6), done. remote: remote: Create a pull request for 'dev' on GitHub by visiting: remote: https://github.com/smangham/climate-analysis/pull/new/dev remote: To github.com:smangham/climate-analysis * [new branch] dev -> dev
origin devmain not devgit switch maingit merge devgit switch devmkdir resultstouch example.csv results/example.txtgit statusgit statusOn branch dev Your branch is up to date with 'origin/dev'. Untracked files: (use "git add <file>..." to include in what will be committed) example.csv results/example.txt nothing added to commit but untracked files present (use "git add" to track)
nano .gitignore*.csv and results/git statusgit add .gitignoregit commit -m "Your message"git statusOn branch dev Your branch is up to date with 'origin/dev'. Untracked files: (use "git add <file>..." to include in what will be committed) .gitignore nothing added to commit but untracked files present (use "git add" to track)