跳到主要内容

Quick Start

提示

This document helps you quickly get started with GitCode, including registration, login, creating a new project, submitting code, and more.

Registration and Login


  • Visit the GitCode website: https://gitcode.com, click on the "Register" button in the top right corner of the homepage, and fill out the required information to register an account.

  • If you already have an account, click the "Login" button in the top right corner. You can choose to log in via SMS or password, and it also supports third-party logins through CSDN, HBuilder, GitHub, Gitee, and WeChat.

  • Here is the content of the video tutorial:

Create a Project


  • After completing registration or successfully logging in, click on the "New" button in the top right corner of the homepage and select "New Project" to create your own project.

  • Concept explanation for parts of the information needed when creating a new project:

  1. Project repository type: GitCode supports different types of repositories for storing code and managing versions.
  • Code repository: Used for storing and managing the source code, script files, and related development resources of a project.
  • Model repository: Used for storing machine learning or deep learning model files and related information.
  • Dataset repository: Used for storing structured or unstructured data, typically datasets required for AI/ML model training and evaluation.
  1. Set the project visibility range: Controls the access permissions for the project.
  • Public project: Accessible by everyone, suitable for open-source projects.
  • Private project: Accessible only by project members, suitable for enterprise or personal projects.
Note

When choosing "Public" for an open-source project, be mindful of protecting sensitive information.

  1. Initialize the project: When creating a project, GitCode provides the following initialization options to help quickly set up the project structure:
  • Add an initial README file: The README is the main documentation page of the project, used to introduce the project's content, features, and usage methods.
  • Add a .gitignore file: Used to ignore files that do not need to be uploaded to the repository, such as local environment configurations, log files, and compiled results.
  • Add a LICENSE file: The LICENSE file declares the usage rights and open-source license of the project.

  • After filling in or selecting all the information, click "Create Project" to create your first project.

Submit Code


After the repository is created, you can submit code using the following process:

  1. Clone the project to your local machine

Before cloning the project, ensure that Git is globally configured locally:

git config --global user.name “Your Name or Nickname”
git config --global user.email “Your Email Address”

Copy the project address and clone it to your local machine:

git clone Project URL

Alternatively, after entering the project, you can click "Clone" on the project page and follow the prompts to clone:

  1. Create a branch

When developing in an enterprise or collaborating with multiple people, we often create multiple branches.

  • Execute the following command to create a new branch:
git branch <new branch name>   # create a new branch
git checkout -b <new branch name> # directly create and switch to a new branch
  • You can also quickly create a new branch by clicking the current branch on the project page and then clicking "New Branch":

If the branch creation is successful, it indicates that a new branch has been successfully created:

  1. Modify code and submit

  • Example of modifying the README.md file using "VSCode":

  • On the project page, you can view the commit history by clicking the "Commits" button on the right:

  • After completing the above steps, you have successfully modified the code and submitted it!

Submit a Pull Request (Read if Collaborative Development Required)


A Pull Request (PR) is a mechanism for code collaboration. It allows developers to submit code changes to the main branch or other branches and merge these changes through code review, testing, and discussion. In enterprise development or collaborative development, we need to submit PRs; if you are a project manager or an individual developer, you may not need to submit a PR.

  1. On the project page, click "Pull Request," then click the "New Pull Request" button on the top right.

  1. Select the corresponding source branch (the branch where you made the code changes) and target branch (the branch to which you want to submit the code), then click "Next."

  1. After filling in the PR title and description, click "Create" to successfully create a PR, notifying the relevant managers to review the PR. Once approved, the code will be synchronized to the merged branch, and the entire PR process ends.

Common Git Commands


The following are common Git commands that can help users quickly master the basic operations of Git.

git init # Initialize a new Git repository.
git remote add origin <remote repository URL> # Add a remote repository
git remote -v # View remote repositories
git add <file name> # Add a specified file
git add . # Add all changed files
git commit -m "Commit message" # Commit changes in the staging area with a message
git log # Show detailed commit history
git log --oneline # Show commit history in a concise format
git status # Check the status of the working directory and staging area.
git branch # List branches
git branch <branch name> # Create a new branch
git branch -d <branch name> # Delete a branch
git checkout <branch name> # Switch to a branch
git checkout -- <file name> # Restore a file to its state at the last commit
git switch <branch name> # Switch branches
git switch -c <branch name> # Create and switch to a new branch
git merge <branch name> # Merge a specified branch into the current branch
git pull # Fetch and merge code from a remote repository into the current branch
git push origin <branch name> # Push local changes to a remote repository
git reset --soft HEAD~1 # Undo the most recent commit but keep the changes
git reset --hard HEAD~1 # Undo the most recent commit and discard the changes
git stash # Save uncommitted changes
git stash pop # Restore stashed changes
git fetch # Fetch updates from a remote repository without merging