Using Git
To use Git on the command line, you will need to download, install, and configure Git on your computer. You can also install GitHub CLI to use GitHub from the command line. For more information, see 关于 GitHub CLI.
If you want to work with Git locally, but do not want to use the command line, you can download and install the GitHub Desktop client. For more information, see 关于 GitHub Desktop.
If you do not need to work with files locally, GitHub lets you complete many Git-related actions directly in the browser, including:
Setting up Git
-
Download and install the latest version of Git.
Note
Most Chrome OS devices from 2020 onwards now have a built-in Linux environment, which includes Git. To enable it, go to the Launcher, search for Linux, and click Turn on.
If you are using an older Chrome OS device, another method is required:
- Install a terminal emulator such as Termux from the Google Play Store on your Chrome OS device.
- From the terminal emulator that you installed, install Git. For example, in Termux, enter
apt install git
and then typey
when prompted.
Authenticating with GitHub from Git
When you connect to a GitHub repository from Git, you will need to authenticate with GitHub using either HTTPS or SSH.
Note
You can authenticate to GitHub using GitHub CLI, for either HTTP or SSH. For more information, see gh auth login
.
Connecting over HTTPS (recommended)
If you clone with HTTPS, you can cache your GitHub credentials in Git using a credential helper. For more information, see About remote repositories and Caching your GitHub credentials in Git.
Connecting over SSH
If you clone with SSH, you must generate SSH keys on each computer you use to push or pull from GitHub. For more information, see About remote repositories and 生成新的 SSH 密钥并将其添加到 ssh-agent.
Next steps
You now have Git and GitHub all set up. You may now choose to create a repository where you can put your projects. Saving your code in a repository allows you to back up your code and share it around the world.
-
为项目创建存储库后,可以将代码存储在 GitHub 中。 这提供了工作备份,你可以选择将其与其他开发人员共享。 有关详细信息,请参阅“仓库快速入门”。
-
为存储库创建分支可以在不影响原始存储库的情况下更改另一个存储库。 有关详细信息,请参阅“为存储库创建分支”。
-
GitHub 中的每个仓库均归个人或组织所有。 可以在 GitHub 上连接和关注人员、仓库和组织以与之进行交互。 有关详细信息,请参阅“在 GitHub 上寻找灵感”。
-
GitHub 有一个强大的支持社区,你可以在那里寻求帮助并与来自世界各地的人交谈。 加入 GitHub Community 上的对话。