【github】初学者使用指南

  • 作者:20岁爱吃必胜客(坤制作人),近十年开发经验, 跨域学习者,目前于新西兰奥克兰大学攻读IT硕士学位
  • 荣誉:阿里云博客专家认证、腾讯开发者社区优质创作者,在CTF省赛校赛多次取得好成绩。
  • 跨领域学习,喜欢摄影、弹吉他、咏春拳。文章深入浅出、语言风趣;爱吃必胜客社区创立者,旨在"发现美 欣赏美

文章目录

要点-commit只是到本地仓库

Enter git commit -m "[commit message]" to save the changes to your local repository. You can enter anything for the commit message, but adding -m "[commit message]" specifies what this code change is doing, so it's helpful to be clear and concise.

本地仓库到github-git

Enter git push origin [branch name] to save your code changes to GitHub.

bash 复制代码
git push origin main

If you haven't already done so, GitHub will prompt you to authenticate your identity. Enter your GitHub username and password. Once the authentication is done, the upload process will start. After it's complete, you'll see specific details about where the data was uploaded.

That's it! You've successfully pushed your local files and folders to your GitHub repository.

To double-check that you pushed to GitHub successfully, open your GitHub repository web page. Your code changes should appear there.

⭐️前言- main

PPS: GitHub has started naming the default branch main instead of master to migrate away from biased terminology (more details available here). In accordance with this industry-wide movement, we have also updated "Learn Git Branching" to use main instead of master in our lessons. This rename should be fairly consistent by now but if you notice any errors, feel free to submit a PR (or open an issue).

🌟 做什么- 改增量

A commit in a git repository records a snapshot of all the (tracked) files in your directory. It's like a giant copy and paste, but even better!

Git wants to keep commits as lightweight as possible though, so it doesn't just blindly copy the entire directory every time you commit. It can (when possible) compress a commit as a set of changes, or a "delta", from one version of the repository to the next.

🌟 保留记录-防作弊

Git also maintains a history of which commits were made when. That's why most commits have ancestor commits above them -- we designate this with arrows in our visualization. Maintaining history is great for everyone working on the project!

☀️总之-是个快照

It's a lot to take in, but for now you can think of commits as snapshots of the project. Commits are very lightweight and switching between them is wicked fast!

☀️一般- 圣经-早提交

branch early, and branch often

Branches in Git are incredibly lightweight as well. They are simply pointers to a specific commit -- nothing more. This is why many Git enthusiasts chant the mantra:

branch early, and branch often

Because there is no storage / memory overhead with making many branches, it's easier to logically divide up your work than have big beefy branches.

When we start mixing branches and commits, we will see how these two features combine. For now though, just remember that a branch essentially says "I want to include the work of this commit and all parent commits."

⭐️做法

GitHub 是一个基于 Git 版本控制系统的代码托管平台,它提供了许多功能来管理代码、协作开发和跟踪项目变更。下面是一些 GitHub 的基本用法:

创建仓库(Repository): 在 GitHub 上创建一个新的代码仓库。点击页面右上角的"+"号,选择"New repository"并填写相关信息即可创建一个新的仓库。

克隆仓库(Clone Repository): 使用 Git 命令或者 GitHub Desktop 将远程仓库复制到本地进行编辑和开发。

bash

Copy code

bash 复制代码
git clone <repository_url>

提交更改(Commit Changes): 将更改保存到本地仓库。使用以下命令:

bash

Copy code

bash 复制代码
git add <file_name>          # 将文件添加到暂存区
git commit -m "Commit message"    # 将暂存区文件提交到本地仓库
git push origin <branch_name>      # 将本地更改推送到远程仓库

分支管理(Branching): 创建新的分支,合并分支或删除分支。

bash

Copy code

bash 复制代码
git branch <branch_name>     # 创建新分支
git checkout <branch_name>   # 切换到指定分支
git merge <branch_name>      # 将指定分支合并到当前分支
git branch -d <branch_name>  # 删除指定分支

拉取更新(Pull Request): 提交更改并请求将其合并到主分支(或其他分支)。在 GitHub 上创建 Pull Request,让其他人审查和讨论更改。

问题追踪(Issue Tracking): 创建问题(issue)来讨论和跟踪工作进度,可以在仓库的 Issues 标签下创建和管理。

GitHub Pages: 使用 GitHub 提供的服务托管静态网页。在仓库的 Settings 中启用 GitHub Pages,并选择要发布的内容目录。

这些是 GitHub 的一些基本用法,当然,GitHub 还有更多功能,比如团队协作、代码审查、Actions 等等,这些功能都有助于更好地管理和协作开发项目。

相关推荐
Tipriest_6 分钟前
GitHub Gist 功能详解:从入门到进阶
github·gist
困惑阿三1 小时前
CloudflarePages+GitHub零成本博客搭建手册
github
猫头虎2 小时前
2026全网最热Claude Skills工具箱,GitHub上最受欢迎的7大Skills开源AI技能库
langchain·开源·prompt·github·aigc·ai编程·agi
CoderJia程序员甲3 小时前
GitHub 热榜项目 - 日榜(2026-02-03)
git·ai·开源·llm·github
MicrosoftReactor5 小时前
技术速递|使用 GitHub Copilot SDK 将智能体集成到任何应用中
ai·github·copilot
极智-99616 小时前
GitHub 热榜项目-日榜精选(2026-02-02)| AI智能体、终端工具、视频生成等 | openclaw、99、Maestro等
人工智能·github·视频生成·终端工具·ai智能体·电子书管理·rust工具
樱花落海洋11120 小时前
GitHub DeskTop Can`t find URP项目
github
我的golang之路果然有问题21 小时前
使用 Hugo + GitHub Pages + PaperMod 主题 + Obsidian 搭建开发博客
golang·go·github·博客·个人开发·个人博客·hugo
codezzzsleep1 天前
fuClaudeBackend:面向fuclaude的轻量后端代理 + Key 管理后台
ai·github·ai编程
kjzd1231 天前
GitHub 热门项目趋势分析报告 (2026年2月2日)
github