### Clone a Git Repository Source: https://docs.gitcode.com/docs/start/quick This command clones a Git repository from a remote URL to your local machine, allowing you to work on the project. ```Git git clone 项目地址 ``` -------------------------------- ### Get Repository Settings (C#) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-repo-settings This C# code example shows how to fetch repository settings using HttpClient. It constructs the request with the necessary URL and headers, sends it, and then prints the JSON response. Ensure you have the correct owner, repo, and access token. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.gitcode.com/api/v5/repos/:owner/:repo/repo_settings"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get File Blob Example Response (JSON) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-git-blobs-sha This is an example JSON response for the GitCode API's get file blob endpoint, illustrating the expected data format for a successful retrieval. ```json { "sha": "e5699fe1b360d6c799ee58b24fb5a670b1e14851", "size": 19, "url": "https://gitcode.com/api/v5/repos/daming_1/zhu_di/git/blobs/e5699fe1b360d6c799ee58b24fb5a670b1e14851", "content": "JXU2RDRCJXU4QkQ1d2ViaG9vaw==", "encoding": "base64" } ``` -------------------------------- ### Common Git Commands Source: https://docs.gitcode.com/docs/start/quick A collection of essential Git commands for managing repositories, tracking changes, branching, merging, and pushing/pulling code. ```Git git init #初始化一个新的 Git 仓库。 git remote add origin <远程仓库地址> # 添加远程仓库 git remote -v # 查看远程仓库 git add <文件名> # 添加指定文件 git add . # 添加所有更改的文件 git commit -m "提交说明" #提交暂存区的更改并备注提交信息 git log # 显示详细提交历史 git log --oneline # 简洁模式 git status #查看工作区和暂存区的状态。 git branch # 查看分支 git branch <分支名> # 创建新分支 git branch -d <分支名> # 删除分支 git checkout <分支名> # 切换到分支 git checkout -- <文件名> # 恢复文件到最近提交的状态 git switch <分支名> # 切换分支 git switch -c <分支名> # 创建并切换到新分支 git merge <分支名> # 将指定分支合并到当前分支 git pull #从远程仓库拉取代码并合并到当前分支 git push origin <分支名> #将本地更改推送到远程仓库 git reset --soft HEAD~1 # 撤销最近一次提交,但保留更改 git reset --hard HEAD~1 # 撤销最近一次提交,并丢弃更改 git stash # 保存未提交的更改 git stash pop # 恢复暂存的更改 git fetch #从远程仓库获取更新,但不合并 ``` -------------------------------- ### Get Repository Contributors (JSON Success Example) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-contributors This is a concrete example of a JSON response for a single contributor, illustrating the data format returned by the GitCode API for repository contributors. ```json { "name": "dengmengmian", "contributions": 3, "email": "my@dengmengmian.com" } ``` -------------------------------- ### 迁移项目(GitHub, Gitee, GitLab) Source: https://docs.gitcode.com/docs/help/home/org_project/project_manage/getting_started/project_creation_and_import GitCode支持直接从GitHub、Gitee、GitLab迁移项目。用户需提供相应平台的个人访问令牌(PAT),GitCode将自动处理克隆和推送过程。目前仅支持项目git仓库的迁移。 ```GitCode 1. 选择迁移平台:选择你要迁移的平台,GitCode 目前支持 Github、Gitee、 GitLab的迁移 2. 选择项目所属帐户:选择要将存储库导入到的 GitCode 帐户/组织 3. 输入个人访问令牌:在页面的对话框中,输入对应平台的个人访问令牌。确保你的令牌具有适当的权限以访问你要导入的项目,系统会自动记住上一次有效的个人访问令牌,你也可以选择更换新的令牌 4. 点击「迁移项目」按钮:点击页面的「迁移项目」按钮 5. 选择要导入的项目:在页面上搜索并选择要导入的项目,建议通过 namespace 快速筛选过滤你要导入的项目,你也可以选择批量导入多个项目 6. 配置导入选项:根据你的需求配置导入选项,例如项目归属、项目路径等 7. 点击「导入项目」:点击「导入」按钮或「批量导入」开始导入项目,系统将自动开始克隆和推送项目仓库到 GitCode 8. 等待导入完成:导入过程可能需要一些时间,具体取决于项目仓库的大小和网络速度。请耐心等待,直到导入完成 ``` -------------------------------- ### Get Repository Contributors (JSON Response Example) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-contributors This is an example of a successful JSON response when fetching repository contributors. It shows the structure of the returned data, including the 'name', 'contributions', and 'email' for each contributor. ```json [ { "name": "string", "contributions": 0, "email": "string" } ] ``` -------------------------------- ### Configure Git User Information Source: https://docs.gitcode.com/docs/start/quick Before cloning a project, ensure Git is configured globally with your username and email. This information is used in commit history. ```Git git config --global user.name "用户名或昵称" git config --global user.email "邮箱地址" ``` -------------------------------- ### Get User Namespace (JSON Response Example) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-user-namespace This is an example of a successful JSON response when retrieving a user's namespace from the GitCode API. It includes fields such as id, path, name, html_url, and type. ```json { "id": 138108, "path": "xiaogang_test", "name": "aaasfd/sda/fsdaf/sdfsa", "html_url": "https://gitcode.com/xiaogang_test", "type": "group" } ``` -------------------------------- ### GitCode Project Response Example Source: https://docs.gitcode.com/docs/apis/post-api-v-5-orgs-org-repos Illustrates a sample JSON response for a GitCode project, showing typical values for project details including namespace and visibility. ```json { "id": 34171993, "full_name": "daming_1/test_create_project_2", "human_name": "daming/test_create_project_2", "url": "https://gitcode.com/api/v5/repos/daming_1/test_create_project_2", "path": "test_create_project_2", "name": "test_create_project_2", "description": "描述", "private": false, "public": true, "namespace": { "id": 74962, "name": "group1111", "path": "group11111", "develop_mode": "normal", "region": null, "cell": "default", "kind": "group", "full_path": "group11111", "full_name": "group1111", "parent_id": null, "visibility_level": 20, "enable_file_control": false, "owner_id": null }, "empty_repo": null, "starred": null, "visibility": "public", "owner": null, "creator": null, "forked_from_project": null, "item_type": null, "main_repository_language": null, "homepage": "http://www.baidi.com" } ``` -------------------------------- ### Get Single Branch API Example Response (JSON) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-branches-branch An example of a successful JSON response when querying a specific branch using the GitCode API. This illustrates the data format for branch name, commit details, and repository status flags. ```json { "name": "dev", "commit": { "id": "b6d44deb0ca73d7a50916d0fea02c72edd6c924e", "message": "\ndev新增文件\n\nCreated-by: csdntest13\nAuthor-id: 494\nMR-id: 68629\nCommit-by: csdntest13\nMerged-by: csdntest13\nE2E-issues: \nDescription: 提交信息\n\nSee merge request: One/One!56", "parent_ids": [ "13956ffeb5e5e1ce60c2ed91d3e579fc50b1f167", "3e42dcb9c09b39972c65536dad71651322470f28" ], "authored_date": "2024-04-15T14:38:50.000Z", "author_name": "csdntest13", "author_iam_id": null, "author_email": "csdntest13@noreply.gitcode.com", "author_user_name": null, "committed_date": "2024-04-15T14:38:50.000Z", "committer_name": "csdntest13", "committer_email": "csdntest13@noreply.gitcode.com", "committer_user_name": null, "open_gpg_verified": null, "verification_status": null, "gpg_primary_key_id": null, "short_id": "b6d44deb", "created_at": "2024-04-15T14:38:50.000Z", "title": "merge refs/merge-requests/56/head into dev", "author_avatar_url": "https://gitcode-img.obs.cn-south-1.myhuaweicloud.com:443/ec/ba/4e7c4661b6154a7dd088d9fe64b4893383a2e318bf362350ce18d44df6ac7e37.png?time=1711533165876", "committer_avatar_url": "https://gitcode-img.obs.cn-south-1.myhuaweicloud.com:443/ec/ba/4e7c4661b6154a7dd088d9fe64b4893383a2e318bf362350ce18d44df6ac7e37.png?time=1711533165876", "relate_url": null }, "merged": false, "protected": false, "developers_can_push": false, "developers_can_merge": false, "can_push": true, "default": false } ``` -------------------------------- ### GitCode Project Creation (C#) Source: https://docs.gitcode.com/docs/apis/post-api-v-5-orgs-org-repos Demonstrates how to create a new project in GitCode using C# and HttpClient. It includes setting request headers, content, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://api.gitcode.com/api/v5/orgs/:org/repos"); request.Headers.Add("Accept", "application/json"); var content = new StringContent("{\n \"name\": \"string\",\n \"description\": \"string\",\n \"homepage\": \"string\",\n \"has_issues\": true,\n \"has_wiki\": true,\n \"can_comment\": true,\n \"public\": 0,\n \"private\": true,\n \"auto_init\": true,\n \"gitignore_template\": \"string\",\n \"license_template\": \"string\",\n \"path\": \"string\",\n \"default_branch\": \"string\",\n \"import_url\": \"string\",\n \"project_template\": \"string\",\n \"repository_type\": \"string\"\n}", null, "application/json"); request.Content = content; var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Repository Commits (HTTP) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-commits Illustrates fetching repository commits using a standard HTTP GET request to the GitCode API. This example shows the request structure and expected headers. ```http GET /api/v5/repos/:owner/:repo/commits HTTP/1.1 Host: api.gitcode.com Accept: application/json ``` -------------------------------- ### 通过URL导入项目 Source: https://docs.gitcode.com/docs/help/home/org_project/project_manage/getting_started/project_creation_and_import 使用URL导入项目功能,可以将外部存储库迁移到GitCode,并利用GitCode的版本控制、问题跟踪等功能。支持代码仓、模型仓或数据集仓的导入,私有项目需提供凭证。 ```GitCode 1. 根据需求选择项目类型:代码仓、模型仓或数据集仓 2. 输入 Git 项目 URL,URL 必须可用且以 `.git` 结尾 3. 私有项目设置(可选),如果导入的项目是一个私有项目,则还需要提供该项目在源托管平台的凭证,支持个人访问令牌(Token)或 用户名+密码 两种方式 4. 选择项目所属帐户:选择要将存储库导入到的 GitCode 帐户/组织 5. 配置导入选项:根据你的需求配置导入选项,例如项目名称、路径描述、是否公开等 6. 等待导入完成:GitCode 将开始导入项目,你可以在导入进度页面上查看导入进度 ``` -------------------------------- ### Get Issue Extend Settings (HTTP) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-orgs-org-issue-extend-settings Demonstrates how to fetch issue extension settings using a standard HTTP GET request. This is a foundational example for understanding API interaction. ```http GET ## https://api.gitcode.com/api/v5/orgs/:org/issue/extend/settings ``` -------------------------------- ### Get User Public Key Example Response Source: https://docs.gitcode.com/docs/apis/get-api-v-5-user-keys-id This is an example of a successful JSON response when retrieving a user's public key from the GitCode API. It includes the key's ID, title, the actual SSH key, creation timestamp, and the API URL. ```json { "id": 308357, "title": "xiaogang@csdn.net\r\n", "key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCwT9UXXtGfLa16tbxV+0RQ6m+BaAG2wJvqApr+juVNEmnM0lKNt1tyxY/V9SsCRf38UprPLTp71+btRpFIH9TLrGhkvT3tJOouYDXVUpSaigi7OO+6eLc+Cn0TZSLj4RmwVe/w93kmsCUzgqkeHk14K3S+2oCCm1rbpBAvpPhSKHhAH9LcTBecDoZ+NA2dsEDyfsloVH5cMJQO9n2W1QYduMuuaVHHpehSdDohN7cDI799Rwofaqqyz6ZJrc6eBjSVi1W+JPDTT6NW0+eFBYXo3KWybffixH4cAWdbS1Ms5Pe9Xh+G4WqFuhFh9zCoXlRUUrArLo5pYfpy5gv4iUVmniM0Pb0/Y5x8RJyGaPdS/2c68s8LQsm/9Ees8aeE5TcT5isDEvh+wy7jp1xi5nONk9QvOy7EdYYeHQtkw/0rklsz7UvAIjjHObNNYpY6RLQRT+dqN/lAb7stT047FSxqcNMCX/cybapLygs1y2ClcgU42p16RfgCH0NKA5emRhM= xiaogang@csdn.net", "created_at": "2024-07-23T10:29:42.119+00:00", "url": "https://api.gitcode.com/v5/user/keys/308357" } ``` -------------------------------- ### Create and Switch Git Branches Source: https://docs.gitcode.com/docs/start/quick Create new branches for new features or bug fixes to isolate changes. You can create a branch and switch to it in one command. ```Git git branch <新分支名> #创建新分支 git checkout -b <新分支名> #直接创建并切换到新分支 ``` -------------------------------- ### HttpClient Initialization Example Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo Demonstrates the basic initialization of an HttpClient object in C#. This is a common starting point for making HTTP requests in .NET applications. ```csharp var client = new HttpClient(); ``` -------------------------------- ### Get Repository Release (Shell) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-releases-tag This snippet provides a shell command example for fetching a single release from a GitCode repository using curl. It illustrates the basic GET request structure. ```shell curl -X GET "https://api.gitcode.com/api/v5/repos/:owner/:repo/releases/:tag" \ -H "accept: application/json" ``` -------------------------------- ### GitCode Project Example Response Source: https://docs.gitcode.com/docs/apis/get-api-v-5-users-username-repos An example of a successful API response for a GitCode project, illustrating the data structure and typical values for project details, owner information, and permissions. ```json { "id": 2734882, "full_name": "dengmengmian/manifest", "human_name": "dengmengmian / manifest", "url": "https://api.gitcode.com/api/v5/repos/dengmengmian/manifest", "namespace": { "id": 199940, "type": "user", "name": "dengmengmian", "path": "dengmengmian", "html_url": "https://gitcode.com/dengmengmian" }, "path": "manifest", "name": "manifest", "description": "manifest", "status": "开始", "ssh_url_to_repo": "git@gitcode.com:dengmengmian/manifest.git", "http_url_to_repo": "https://gitcode.com/dengmengmian/manifest.git", "web_url": "https://gitcode.com/dengmengmian/manifest", "homepage": "https://gitcode.com/dengmengmian/manifest", "members": [ "dengmengmian" ], "assignee": [ { "id": "268", "login": "dengmengmian", "name": "麻凡", "avatar_url": "https://cdn-img.gitcode.com/ec/fb/430ecf07b9ee91bbbbf341d92a36783d06e69086f82ce8cf5a6406f79f1c9cf4.png", "html_url": "https://gitcode.com/dengmengmian", "type": "User" } ], "forks_count": 0, "stargazers_count": 0, "project_labels": [], "relation": "master", "permission": { "pull": true, "push": true, "admin": true }, "internal": false, "open_issues_count": 0, "has_issue": false, "watched": false, "watchers_count": 0, "assignees_number": 1, "enterprise": { "id": 199940, "path": "dengmengmian", "html_url": "https://gitcode.com/dengmengmian", "type": "user" }, "default_branch": "master", "fork": false, "owner": { "id": "268", "login": "dengmengmian", "name": "麻凡", "type": "User" }, "assigner": { "id": "268", "login": "dengmengmian", "name": "麻凡", "type": "User" }, "issue_template_source": null, "private": 0, "public": 1, "gitee": { "star": 0, "fork": 0, "watch": 0 } } ``` -------------------------------- ### Get Project Custom Roles JSON Example Response Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-customized-roles This is an example JSON response from the GitCode API for fetching custom project roles. It provides sample data for a role, including its ID, access level, names, description, type, member count, and creation/update times. ```json { "role_id": "e6cd76d6c82f46c78c71fd7f67eaf3bf", "access_level": 15, "role_name": "测试角色", "role_chinese_name": "测试角色", "role_description": "测试角色", "role_type": "project-customized", "member_count": 1, "created_at": "2024-04-17 08:00", "updated_at": "2024-04-17 08:00" } ``` -------------------------------- ### Git 初始化新版本库 Source: https://docs.gitcode.com/docs/help/home/general-reference/git 使用 `git init` 命令创建一个新的 Git 版本库。此命令会在当前目录创建 `.git` 文件夹,用于存储版本库的配置、日志和分支信息。 ```shell $ git init ``` -------------------------------- ### Get Enterprise Issue Comments (HTTP) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-enterprises-enterprise-issues-number-comments This example shows a basic HTTP GET request to the GitCode API endpoint for fetching enterprise issue comments. It outlines the URL structure and the expected response format. ```http GET https://api.gitcode.com/api/v5/enterprises/:enterprise/issues/:number/comments --header "access_token: YOUR_ACCESS_TOKEN" --header "page: 1" --header "per_page: 20" ``` -------------------------------- ### Get Organization Information (C# HttpClient) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-orgs-org This C# code example shows how to use HttpClient to make a GET request to the GitCode API to retrieve organization details. It includes setting the request method, URL, and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.gitcode.com/api/v5/orgs/:org"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### GitCode Pipeline YAML Configuration Source: https://docs.gitcode.com/docs/help/home/org_project/pipeline/pipeline-intro1 Example YAML file for defining a GitCode pipeline. It specifies the trigger events (push and pull_request to main branch) and a 'build' job that runs on a specific runner, using checkout and setup-node actions, and executing npm commands for installation, building, and testing. ```yaml name: gitcode-sample on: push: branches: [ "main" ] pull_request: branches: [ "main" ] jobs: build: runs-on: euleros-2.10.1 steps: - uses: checkout-action@0.0.1 - name: Use Node.js uses: setup-node@0.0.1 with: node-version: '20.10.0' - run: cd repo_workspace && npm ci - run: cd repo_workspace && npm run build --if-present - run: cd repo_workspace && npm test ``` -------------------------------- ### Fetch User Starred Repositories (C# HttpClient) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-user-starred Demonstrates how to fetch a list of a user's starred repositories using C#'s HttpClient. It shows how to create an HTTP request, set the method and URL, and add necessary headers like 'Accept'. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.gitcode.com/api/v5/user/starred"); request.Headers.Add("Accept", "application/json"); ``` -------------------------------- ### Get GitCode Pull Request Commits (HTTP) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-pulls-number-commits This example shows a basic HTTP GET request to the GitCode API to fetch commits for a pull request. It specifies the endpoint URL and the required 'Accept' header for JSON response. ```http GET https://api.gitcode.com/api/v5/repos/:owner/:repo/pulls/:number/commits Accept: application/json ``` -------------------------------- ### Get Pull Request Settings (C#) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-pull-request-settings This C# code example shows how to fetch pull request settings using HttpClient. It constructs the GET request, sets the appropriate headers, sends the request, and processes the JSON response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.gitcode.com/api/v5/repos/:owner/:repo/pull_request_settings"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### GitCode API Successful Response Example Source: https://docs.gitcode.com/docs/apis/get-api-v-5-user-starred Provides a concrete example of a successful API response, illustrating the data structure for a specific repository. This helps developers understand the expected output format and values. ```json { "id": 777621, "full_name": "xiaogang/private-new2", "human_name": "xiaogang / private-new2", "url": "https://api.gitcode.com/api/v5/repos/xiaogang/private-new2", "namespace": { "id": 137117, "type": "user", "name": "xiaogang", "path": "xiaogang", "html_url": "https://gitcode.com/xiaogang" }, "path": "private-new2", "name": "private-new2", "parentfull_name": "xiaogang_test/private-new", "description": "特朗普", "status": "开始", "ssh_url_to_repo": "ssh://git@gitcode.com:2222/xiaogang/private-new2.git", "http_url_to_repo": "https://gitcode.com/xiaogang/private-new2.git", "web_url": "https://gitcode.com/xiaogang/private-new2", "created_at": "2024-12-11T17:41:14.536+08:00", "updated_at": "2024-12-11T17:41:14.536+08:00", "homepage": "https://gitcode.com/xiaogang/private-new2", "members": [ "xiaogang" ], "parent": { "full_name": "xiaogang_test/private-new", "human_name": "xiaogang_test / private-new" }, "forks_count": 0, "stargazers_count": 1, "relation": "master", "permission": { "pull": true, "push": true, "admin": true }, "internal": false, "open_issues_count": 0, "has_issue": false, "has_issues": false, "watchers_count": 0, "enterprise": { "id": 137117, "path": "xiaogang", "html_url": "https://gitcode.com/xiaogang", "type": "user" }, "default_branch": "main", "fork": true, "pushed_at": "2024-12-20T19:14:34.979+08:00", "owner": { "id": "496", "login": "xiaogang", "name": "肖刚", "type": "User" }, "issue_template_source": "project", "project_creator": "xiaogang", "private": false, "public": true } ``` -------------------------------- ### Get Protected Branches List (C# HttpClient) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-protect-branches This C# code example shows how to use HttpClient to make a GET request to the GitCode API to retrieve protected branch information. It includes setting the request URL and handling the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.gitcode.com/api/v5/repos/:owner/:repo/protect_branches"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Git 获取帮助信息 Source: https://docs.gitcode.com/docs/help/home/general-reference/git 使用 `git help` 命令可以获取 Git 命令的详细帮助文档。可以不带参数查看所有可用命令,或指定命令名查看特定命令的帮助。 ```shell # 查找可用命令 $ git help # 查找所有可用命令 $ git help -a # 在文档当中查找特定的命令 # git help <命令> $ git help add $ git help commit $ git help init ``` -------------------------------- ### Get Repository Milestone (cURL) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-milestones-number This example shows how to fetch a GitCode repository milestone using cURL. It specifies the HTTP method (GET) and the API endpoint, including placeholders for owner, repo, and number. The access_token is passed as a query parameter. ```curl GET https://api.gitcode.com/api/v5/repos/:owner/:repo/milestones/:number?access_token=user_authorization_code ``` -------------------------------- ### GitCode API Successful Example Response Source: https://docs.gitcode.com/docs/apis/get-api-v-5-user-repos An example of a successful response from the GitCode API, showcasing a populated repository object with details like full name, URLs, owner information, and permissions. ```json { "id": 4028329, "full_name": "tiandi/test_yf_repo", "human_name": "洪门 / test_yf_repo", "url": "https://api.gitcode.com/api/v5/repos/tiandi/test_yf_repo", "namespace": { "id": 1420034, "type": "enterprise", "name": "洪门", "path": "tiandi", "html_url": "https://gitcode.com/tiandi" }, "path": "test_yf_repo", "name": "test_yf_repo", "description": "", "status": "开始", "ssh_url_to_repo": "git@gitcode.com:tiandi/test_yf_repo.git", "http_url_to_repo": "https://gitcode.com/tiandi/test_yf_repo.git", "web_url": "https://gitcode.com/tiandi/test_yf_repo", "homepage": "https://gitcode.com/tiandi/test_yf_repo", "members": [ "aron1" ], "assignee": [ { "id": "332008", "login": "aron1", "name": "yanfan", "avatar_url": "https://cdn-img.gitcode.com/bd/ca/0115343247b338d0c53589a145501e84a58464272f2fb09b372cc3d2311b2b39.png?time=1722525295285", "html_url": "https://gitcode.com/aron1", "type": "User" } ], "forks_count": 0, "stargazers_count": 0, "project_labels": [], "relation": "master", "permission": { "pull": true, "push": true, "admin": true }, "internal": false, "open_issues_count": 0, "has_issue": false, "watched": false, "watchers_count": 0, "assignees_number": 1, "enterprise": { "id": 1420034, "path": "tiandi", "html_url": "https://gitcode.com/tiandi", "type": "enterprise" }, "default_branch": "main", "fork": false, "owner": { "id": "444601", "login": "yanfan", "name": "yanfan是随时随地送达啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊实打实", "type": "User" }, "assigner": { "id": "444601", "login": "yanfan", "name": "yanfan是随时随地送达啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊实打实", "type": "User" }, "private": true, "public": false } ``` -------------------------------- ### GitCode Project Schema Example Source: https://docs.gitcode.com/docs/apis/post-api-v-5-orgs-org-repos Provides a JSON schema example for a GitCode project, outlining the expected fields and their data types for a successful response. ```json { "id": 0, "full_name": "string", "human_name": "string", "url": "string", "path": "string", "name": "string", "description": "string", "private": 0, "public": 0, "namespace": { "id": 0, "name": "string", "path": "string", "develop_mode": "string", "cell": "string", "kind": "string", "full_path": "string", "full_name": "string", "visibility_level": 0, "enable_file_control": 0 }, "visibility": "string", "homepage": "string" } ``` -------------------------------- ### Get Repository Events (C#) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-events-access-token-your-token This C# code example shows how to use HttpClient to make a GET request to the GitCode API for repository events. It sets up the request, adds necessary headers, sends the request, and processes the successful response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.gitcode.com/api/v5/repos/:owner/:repo/events"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Repository Commit (JSON Example) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-repos-owner-repo-commits-sha Provides an example of a successful JSON response when retrieving commit details from the GitCode API. It includes fields for the commit URL, SHA, HTML URL, comments URL, commit details (author, committer, message), stats (additions, deletions, total), and an array of changed files. ```json { "url": "string", "sha": "string", "html_url": "string", "comments_url": "string", "commit": { "author": { "name": "string", "date": "string", "email": "string" }, "committer": { "name": "string", "date": "string", "email": "string" }, "message": "string" }, "stats": { "additions": 0, "deletions": 0, "total": 0 }, "files": [ { "filename": "string", "raw_url": "string", "content_url": "string" } ] } ``` -------------------------------- ### Get Enterprise Labels (HTTP) Source: https://docs.gitcode.com/docs/apis/get-api-v-8-enterprises-enterprise-labels This example shows an HTTP GET request to retrieve enterprise labels from the GitCode API. It specifies the endpoint URL and includes the required 'enterprise' path parameter and 'access_token' query parameter. The Accept header is set to 'application/json'. ```http GET /api/v8/enterprises/:enterprise/labels?access_token=YOUR_ACCESS_TOKEN HTTP/1.1 Host: api.gitcode.com Accept: application/json ``` -------------------------------- ### GitCode API Example Response: printf Repository Source: https://docs.gitcode.com/docs/apis/get-api-v-5-search-repositories An example of a successful response for the 'printf' repository. It includes details such as repository name, description, URLs, and timestamps, similar to other repository responses. ```JSON { "id": 1401745, "full_name": "gh_mirrors/pr/printf", "human_name": "GitHub 加速计划 / pr / printf", "url": "https://api.gitcode.com/api/v5/repos/gh_mirrors/pr/printf", "namespace": { "id": 2192766, "type": "enterprise", "name": "pr", "path": "pr", "html_url": "https://gitcode.com/pr" }, "path": "printf", "name": "printf", "description": "Tiny, fast, non-dependent and fully loaded printf implementation for embedded systems. Extensive test suite passing.", "status": "开始", "ssh_url_to_repo": "git@gitcode.com:gh_mirrors/pr/printf.git", "http_url_to_repo": "https://gitcode.com/gh_mirrors/pr/printf.git", "web_url": "https://gitcode.com/gh_mirrors/pr/printf", "created_at": "2023-12-16T20:28:57.687+08:00", "updated_at": "2024-09-27T21:48:26.980+08:00", ``` -------------------------------- ### Get Organization Enterprise using HttpClient in C# Source: https://docs.gitcode.com/docs/apis/get-api-v-8-org-org-enterprise This C# code example shows how to use the `HttpClient` class to make a GET request to the GitCode API for retrieving organization enterprise details. It sets the request method, URL, and headers, and handles the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.gitcode.com/api/v8/org/:org/enterprise"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Fetch User Repositories with C# HttpClient Source: https://docs.gitcode.com/docs/apis/get-api-v-5-users-username-repos This snippet demonstrates how to fetch a user's repositories using C# with the HttpClient class. It sends a GET request to the GitCode API v5 and prints the response. ```csharp var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.gitcode.com/api/v5/users/:username/repos"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ``` -------------------------------- ### Get Repository Commit Statistics (C#) Source: https://docs.gitcode.com/docs/apis/get-api-v-5-owner-repo-repository-commit-statistics This C# code example demonstrates how to use HttpClient to make a GET request to the GitCode API for commit statistics. It sets up the request, adds necessary headers, sends the request, and prints the JSON response. ```C# var client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Get, "https://api.gitcode.com/api/v5/:owner/:repo/repository/commit_statistics"); request.Headers.Add("Accept", "application/json"); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); Console.WriteLine(await response.Content.ReadAsStringAsync()); ```