Tutorials
Instructions on Version Control System (Git & Github)
-
GitHub setup (Link):
- Step 1: Open the terminal → Check if SSH exists on your Mac by entering the
command
cd ~/.ssh
→ If it doesn't exist, create an SSH key by runningssh-keygen -t rsa -C xxxxx@163.com
(replace xxxxx@163.com with the email you used when registering on GitHub) → It will prompt you to choose the storage location for the SSH key. Press Enter to use the default location and follow the prompts to complete the process by entering 'y' when prompted for confirmation. → Finally, set a password for the SSH key. Enter a password, confirm it, and the SSH key creation process will be completed. - Step 2:
ssh -T git@github.com
is used to test the SSH connection between your local machine and GitHub. It verifies if your SSH key is associated with your GitHub account. - Step 3: Upload files from local to Github.
git clone https://github.com/xxx.git
(address of repository in your own Github).- Navigate to the local folder: Open the terminal and use the
cd
command to navigate to the local folder where you want to upload the files (Or create a new file that you want to upload usingtouch README.md
). git add filename.txt
(add a specific file) Orgit add .
(add all the files in the folder).git commit -m “first version(Description of the commit)”
git remote add origin git@github.com:username/xxx.git
git push origin HEAD:main
Orgit push origin
- Step 4: Create a new branch.
git branch bname
, create a branch named bname.git checkout bname
, switch the HEAD in git to the created new branch, bname.git add filename.txt (add a specific file)
(add all the file in the folder).Or
git add .git commit -m “first version(Description of the commit)”
git remote add origin git@github.com:username/xxx.git
git push origin HEAD:bename
git checkout bname
, switch HEAD to bname.git checkout c1
, move HEAD to the c1 commit.git merge bname
, merge changes on the bname branch into the current branch.git branch -D bname
, delete the branch named bname.
- Step 1: Open the terminal → Check if SSH exists on your Mac by entering the
command
-
Large files uploading to github:
- Step 1: Navigate to the Directory: Open your terminal or command prompt and navigate to the directory containing the large file you want to upload.
- Step 2: Initialize Git LFS: If you haven't already initialized Git LFS for your
repository, you can do so by running:
git lfs install - Step 3: Track Large File: Track the large file using Git LFS. You need to specify
the relative path to the file from the root directory of your repository. For example, if the large
file is located in a subdirectory named "data" and its filename is "large _file.zip", you can run:
git lfs track data/large _file.zip - Step 4: Add and Commit Large File: Add the large file to the staging area and
commit it to your local repository as you normally would:
git add .gitattributes git commit -m "Track large files with Git LFS" git add data/large _file.zip git commit -m "Add large file using Git LFS" - Step 5: Push Changes to GitHub: Once you've committed the changes locally, you
can
push them to your GitHub repository:
git push origin main - Step 6: Verify Large File in GitHub: After pushing the changes, verify that the large file is properly stored using Git LFS in your GitHub repository.
- Step 7: Download Large File from Github: Clone this repository to your local PC
and
navigate to the directory and download the data from github LFS:
git clone https://github.com/xxx.git git lfs ls-files git lfs pull
-
Version Control Git (CLM as an example):
- Step 1: In the Arctic Carbon Cycle Updates Request of CLM, we can see the first
commit is
64aa4d9
, the last commit isdd0cbec
. Therefore, the commits of dd0cbec is the abz version of CLM, and the commitbefore 64aa4d9
is the version without abz updates.Arctic Carbon Cycle Updates Request of CLM in github repository. - Step 2:
git clone ****
, download the CLM to the location you want. Then,cd CTSM
and usegit branch
, we can see this version is pointing to the master branch.Clone repository. - Step 3: Now, to get the arctic carbon cycle updates version of CLM, using command
line
git checkout dd0cbec
. Then,git checkout -b abz_version
(build a new branch named abz_version). Andgit log --oneline
, you can see the last commit is pointing atdd0cbec
, which is the last commit of abz.Get the updated version of CLM. - Step 4: The first commit of abz updates is
64aa4d9
, which means the commit before64aa4d9
is the version without abz updates, namely384c726
. So, we cangit checkout 384c726
to transfer the current version before abz updates. Thengit branch -b no_abz
(build a branch before abz updates). - Step 5: Finally,
git branch
, we can see there are three branches(master, abz_updates, no_abz)
.Finalize the extracted branches with different versions of CLM.
- Step 1: In the Arctic Carbon Cycle Updates Request of CLM, we can see the first
commit is