Week5-2_Github_Collaborator
English translation
1. Add a collaborator to your repository
- Repository - Settings - Manage access - Invite a collaborator
- An invited user becomes a collaborator upon accepting the invitation.
- The following instructions are for the invited user.
2. Clone from the remote repository
- For convenience, this notebook uses a temporary folder on Google Drive instead of the invited user's local drive.
from google.colab import drive
drive.mount('/content/drive')Mounted at /content/drive
cd /content/drive/MyDrive//content/drive/MyDrive
mkdir tempcd temp/content/drive/MyDrive/temp
!git clone "https://github.com/chorok-daddy/repository-basic.git"Cloning into 'repository-basic'... remote: Enumerating objects: 15, done.[K remote: Counting objects: 100% (15/15), done.[K remote: Compressing objects: 100% (10/10), done.[K remote: Total 15 (delta 3), reused 2 (delta 0), pack-reused 0[K Unpacking objects: 100% (15/15), done.
cd repository-basic//content/drive/My Drive/temp/repository-basic
!git config --local user.email "chorok.crew@gmail.com"
!git config --local user.name "chorok-crew"
3. Edit Readme.md
- Refer to the previous materials.
4. Commit locally
!git add .
!git commit -m "Edit Readme.md by chorok.crew"[main 4ada371] Edit Readme.md by chorok.crew 1 file changed, 3 insertions(+), 1 deletion(-)
5. Push to the remote repository
- A collaborator has the same permissions as the repository owner, including permission to push to main.
!git remote add repo-basic https://collaborator_username:token@github.com/chorok-daddy/repository-basic.git!git push -u repo-basic mainCounting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 50% (1/2) Compressing objects: 100% (2/2) Compressing objects: 100% (2/2), done. Writing objects: 33% (1/3) Writing objects: 66% (2/3) Writing objects: 100% (3/3) Writing objects: 100% (3/3), 359 bytes | 119.00 KiB/s, done. Total 3 (delta 1), reused 0 (delta 0) remote: Resolving deltas: 100% (1/1), completed with 1 local object.[K To https://github.com/chorok-daddy/repository-basic.git 0ecdaa4..4ada371 main -> main Branch 'main' set up to track remote branch 'main' from 'repo-basic'.
6. Create a branch
- !git checkout [branch-name] : Switch to the specified branch.
- -b option: Create a new branch and switch to it.
!git checkout -b branch01Switched to a new branch 'branch01'
!git statusOn branch branch01 nothing to commit, working tree clean
!git branch* [32mbranch01[m main[m
7. Edit Readme.md on the branch
8. Commit the changes and push to the remote
!git add .
!git commit -m "Edit Readme.md in Branch01"[branch01 27e8e07] Edit Readme.md in Branch01 1 file changed, 3 insertions(+)
!git push repo-basic branch01Counting objects: 3, done. Delta compression using up to 2 threads. Compressing objects: 50% (1/2) Compressing objects: 100% (2/2) Compressing objects: 100% (2/2), done. Writing objects: 33% (1/3) Writing objects: 66% (2/3) Writing objects: 100% (3/3) Writing objects: 100% (3/3), 335 bytes | 167.00 KiB/s, done. Total 3 (delta 1), reused 0 (delta 0) remote: Resolving deltas: 0% (0/1)[K remote: Resolving deltas: 100% (1/1)[K remote: Resolving deltas: 100% (1/1), completed with 1 local object.[K remote: remote: Create a pull request for 'branch01' on GitHub by visiting:[K remote: https://github.com/chorok-daddy/repository-basic/pull/new/branch01[K remote: To https://github.com/chorok-daddy/repository-basic.git * [new branch] branch01 -> branch01
9. Merge (Pull Request)