【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 等等,这些功能都有助于更好地管理和协作开发项目。

相关推荐
消防大队VUE支队5 小时前
家里到底连了多少设备?这款开源神器让你一目了然
github
逛逛GitHub6 小时前
9 个 超绝的 AI 控制电脑 GitHub 开源项目。
github
QC七哥9 小时前
伪造git提交记录生成点阵字符
git·github
TimberWill9 小时前
GitHub Copilot 一键生成中文commit提示语规则设置
git·github
徐小夕10 小时前
pxcharts 多维表格开源!一款专为开发者和数据分析师打造的轻量化智能表格
前端·架构·github
NocoBase11 小时前
GitHub 上星星数量前 10 的 AI CRM 开源项目
人工智能·低代码·开源·github·无代码
CoderJia程序员甲12 小时前
GitHub 热榜项目 - 日榜(2025-12-22)
ai·开源·大模型·github·ai教程
cnnews13 小时前
某讯T1刷armbian
linux·ubuntu·开源·github
bj_zhb13 小时前
git reflog用法
大数据·linux·git·github