Skip to content

Instantly share code, notes, and snippets.

@dk0893
Created March 13, 2024 10:45
Show Gist options
  • Save dk0893/a4829851362f08f966463648fe0088eb to your computer and use it in GitHub Desktop.
Save dk0893/a4829851362f08f966463648fe0088eb to your computer and use it in GitHub Desktop.
git.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"mount_file_id": "14MlINy-2reAMH-aiY_CHDpoaEvpCMfux",
"authorship_tag": "ABX9TyMqvYbsGjG8tkErJnGUMjpy",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/dk0893/a4829851362f08f966463648fe0088eb/git.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"# ◆自分のGitHubの操作"
],
"metadata": {
"id": "8L0_BS1Xf1HO"
}
},
{
"cell_type": "code",
"source": [
"!pwd\n",
"%cd drive/MyDrive/GitHub/\n",
"!ls -aF"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "WcVHBWtVgFyO",
"outputId": "2e7e08cd-fe49-4e5b-fdc2-4aabb772c5af"
},
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content\n",
"/content/drive/MyDrive/GitHub\n",
"deep-learning-from-scratch-4/ experiment/ git.ipynb\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!git clone https://github.com/dk0893/experiment.git"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "wPXbALpvgOM9",
"outputId": "056aa68c-68f2-4724-d3cb-2c6fd9824cc2"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Cloning into 'experiment'...\n",
"remote: Enumerating objects: 6, done.\u001b[K\n",
"remote: Counting objects: 100% (6/6), done.\u001b[K\n",
"remote: Compressing objects: 100% (4/4), done.\u001b[K\n",
"remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0\u001b[K\n",
"Receiving objects: 100% (6/6), 24.58 KiB | 740.00 KiB/s, done.\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"%cd experiment/\n",
"!ls -aF"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "NNjEApu8gccu",
"outputId": "2ef1b6fc-39b7-4c47-b193-3b4a2367944f"
},
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content/drive/MyDrive/GitHub/experiment\n",
".git/ matplotlib_animation.ipynb notebook/ README.md\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!git config --global user.name \"dk0893\"\n",
"!git config --global user.email \"dk0893@gmail.com\""
],
"metadata": {
"id": "IoQA59qFiOhO"
},
"execution_count": 18,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!git remote set-url origin \"https://TOKEN@github.com/dk0893/experiment.git\"\n",
"!git remote -v"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "1teZJEu_ipYZ",
"outputId": "b3749f41-cb9d-43ad-a7ed-e20984efb8fc"
},
"execution_count": 21,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"origin\thttps://TOKEN@github.com/dk0893/experiment.git (fetch)\n",
"origin\thttps://TOKEN@github.com/dk0893/experiment.git (push)\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!git status"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "ksAdc7JGh7ea",
"outputId": "4fe2af6a-303a-4238-ef60-1d7a43eac83d"
},
"execution_count": 11,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"On branch main\n",
"Your branch is up to date with 'origin/main'.\n",
"\n",
"nothing to commit, working tree clean\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!git pull\n",
"!ls -aF"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "Wtuc_OWPhf5g",
"outputId": "ed9e38cc-6545-4a5a-c84c-b54b53e7d4d5"
},
"execution_count": 13,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Already up to date.\n",
".git/ matplotlib_animation.ipynb notebook/ README.md\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!ls -aF\n",
"!rm notebook/matplotlib_animation"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "qYzAeKighu-H",
"outputId": "bfca1196-5621-4af9-f6f0-d0b9d7a05b53"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
".git/ notebook/ README.md\n",
"rm: cannot remove 'notebook/matplotlib_animation': No such file or directory\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!mkdir notebook"
],
"metadata": {
"id": "GPLkM31tglVp"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"!git mv matplotlib_animation.ipynb notebook/matplotlib_animation.ipynb\n",
"!ls -aF"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "c8iNArzigwtD",
"outputId": "0a8699bb-7c0b-476c-b321-21773ca10f07"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
".git/ notebook/ README.md\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!git rm -f matplotlib_animation.ipynb\n",
"!ls -aF"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "C2WXORgLVqRr",
"outputId": "a09dec8e-9b98-479b-b1d7-ee65f1458e7f"
},
"execution_count": 15,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"rm 'matplotlib_animation.ipynb'\n",
".git/ notebook/ README.md\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!git commit -m \"rm matplotlib_animation.ipynb\""
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "1szo_UJhiEMx",
"outputId": "eb5ee892-b159-48c9-b5b1-04f68626d46d"
},
"execution_count": 19,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"[main 6b8e24b] rm matplotlib_animation.ipynb\n",
" 1 file changed, 1727 deletions(-)\n",
" delete mode 100644 matplotlib_animation.ipynb\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!git push"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "pBKMUZyuifoL",
"outputId": "0f50938f-f064-4a37-dccb-e222b987bfec"
},
"execution_count": 20,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Enumerating objects: 3, done.\n",
"Counting objects: 33% (1/3)\rCounting objects: 66% (2/3)\rCounting objects: 100% (3/3)\rCounting objects: 100% (3/3), done.\n",
"Delta compression using up to 2 threads\n",
"Compressing objects: 50% (1/2)\rCompressing objects: 100% (2/2)\rCompressing objects: 100% (2/2), done.\n",
"Writing objects: 50% (1/2)\rWriting objects: 100% (2/2)\rWriting objects: 100% (2/2), 273 bytes | 34.00 KiB/s, done.\n",
"Total 2 (delta 0), reused 0 (delta 0), pack-reused 0\n",
"To https://github.com/dk0893/experiment.git\n",
" 9f0338a..6b8e24b main -> main\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!git reset --hard origin/main"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "3xivD_UIpxBX",
"outputId": "10c90b41-5980-447a-ae89-39d018dadf4f"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"HEAD is now at 9f0338a 移動後の確認コミット\n"
]
}
]
},
{
"cell_type": "markdown",
"source": [
"# ◆自分のリポジトリではないGitの操作"
],
"metadata": {
"id": "W6zIl__Yf4yr"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "O0vWGFYBYCWI",
"outputId": "ed91137b-4357-4f8a-c5ff-64c235f32b93"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"/content\n",
"/content/drive/MyDrive/GitHub\n",
"git.ipynb\n"
]
}
],
"source": [
"!pwd\n",
"#!ls -aF drive/MyDrive/GitHub/\n",
"%cd drive/MyDrive/GitHub/\n",
"!ls -aF"
]
},
{
"cell_type": "code",
"source": [
"!git clone https://github.com/oreilly-japan/deep-learning-from-scratch-4.git"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "fNf98ZqmYvWb",
"outputId": "f57e416b-5892-453f-b7d3-39409ca09386"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Cloning into 'deep-learning-from-scratch-4'...\n",
"remote: Enumerating objects: 411, done.\u001b[K\n",
"remote: Counting objects: 100% (20/20), done.\u001b[K\n",
"remote: Compressing objects: 100% (13/13), done.\u001b[K\n",
"remote: Total 411 (delta 11), reused 11 (delta 7), pack-reused 391\u001b[K\n",
"Receiving objects: 100% (411/411), 1.02 MiB | 4.35 MiB/s, done.\n",
"Resolving deltas: 100% (235/235), done.\n"
]
}
]
},
{
"cell_type": "code",
"source": [
"!ls -aF"
],
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "4rzwA4AgYTYC",
"outputId": "0a1810df-b0bf-4365-86a1-439ad0fd250a"
},
"execution_count": null,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"deep-learning-from-scratch-4/ git.ipynb\n"
]
}
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "6ZRu8pG5Ygsy"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment