Git 初学者:权威实用指南 [英] Git for beginners: The definitive practical guide
问题描述
好的,在看到 这篇 PJ Hyett 的帖子后,我决定跳到最后,使用 Git.
Ok, after seeing this post by PJ Hyett, I have decided to skip to the end and go with Git.
所以我需要的是 Git 的初学者实用指南.初学者"被定义为知道如何处理他们的编译器的人,在某种程度上理解 Makefile 是,并且在不太了解它的情况下接触了源代码控制.
So what I need is a beginner's practical guide to Git. "Beginner" being defined as someone who knows how to handle their compiler, understands to some level what a Makefile is, and has touched source control without understanding it very well.
实用"被定义为这个人不想详细了解 Git 在后台做什么,甚至不关心(或知道)它是分布式的.您的回答可能暗示了这些可能性,但请尝试针对希望将主"存储库保留在备份和安全的服务器"上的初学者,并将其本地存储库仅视为客户端"资源.
"Practical" being defined as this person doesn't want to get into great detail regarding what Git is doing in the background, and doesn't even care (or know) that it's distributed. Your answers might hint at the possibilities, but try to aim for the beginner that wants to keep a 'main' repository on a 'server' which is backed up and secure, and treat their local repository as merely a 'client' resource.
所以:
- 如何安装 Git
- 您如何设置 Git?尝试涵盖 Linux、Windows、Mac,想想客户端/服务器"的心态.
- 如何获取最新代码?
- 如何查看代码?莉>
- 您如何提交更改?
- 您如何查看未提交的内容,或者您当前的状态代码库?
- 如何销毁不需要的提交?莉>
- 您如何比较文件的两个修订版,或您当前的文件和以前的修订版本?
- 如何查看文件的修订历史?
- 您如何处理二进制文件(例如,visio 文档或编译器环境)?
- 如何合并同时"更改的文件?
- 如何撤消(还原或重置)提交?
- 您如何标记"标记"或发布"一组特定文件的一组特定修订,以便您以后可以随时提取该修订?
- 您如何提取特定的版本"?
- 你如何分支?莉>
- 如何合并分支?
- 您如何解决冲突并完成合并?
- 如何将一个分支的部分合并到另一个分支中?
- 什么是变基?
- 如何跟踪远程分支?
- 如何在远程存储库上创建分支?
- 如何删除远程存储库上的分支?
- Git 工作流程示例
- 描述并链接到使 Git 成为非命令行资源的优秀 GUI、IDE 插件等,但请列出其局限性和优点.
- msysgit - 跨平台,包含在 Git 中
- gitk - 跨平台历史查看器,随附git
- gitnub - Mac OS X
- gitx - Mac OS X 历史查看器莉>
- smartgit - 跨平台、商业、测试版
- tig - Linux 控制台 GUI
- qgit - 适用于 Windows、Linux 的 GUI
- Git 扩展 - 适用于 Windows 的软件包,包括友好的图形界面
- Describe and link to a good GUI, IDE plugin, etc. that makes Git a non-command line resource, but please list its limitations as well as its good.
- msysgit - Cross platform, included with Git
- gitk - Cross platform history viewer, included with Git
- gitnub - Mac OS X
- gitx - Mac OS X history viewer
- smartgit - Cross platform, commercial, beta
- tig - console GUI for Linux
- qgit - GUI for Windows, Linux
- Git Extensions - package for Windows, includes friendly GUI
- Git 指南
- Git 书
- Git 魔法
- gitcasts
- GitHub 指南
- Git 教程
- Progit - Scott Chacon 着的书
- Git - SVN 速成课程
- 自下而上的 Git
- Git 准备就绪
- gitref.org
- Git 可视化备忘单
我会不时浏览条目并整理"它们,使它们具有一致的外观/感觉,并且易于浏览列表 - 随意遵循简单的标题 - 简要说明 - 说明列表"- 陷阱和额外信息"模板.我还将链接到上面项目符号列表中的条目,以便以后轻松找到它们.
I will go through the entries from time to time and 'tidy' them up so they have a consistent look/feel and it's easy to scan the list - feel free to follow a simple "header - brief explanation - list of instructions - gotchas and extra info" template. I'll also link to the entries from the bullet list above so it's easy to find them later.
推荐答案
您如何创建新项目/存储库?
git 存储库只是一个包含特殊
.git
目录的目录.这与集中式"不同版本控制系统(如 subversion),其中存储库"托管在远程服务器上,您可以
checkout
到工作副本"中;目录.使用 git,您的工作副本是存储库.This is different from "centralised" version-control systems (like subversion), where a "repository" is hosted on a remote server, which you
checkout
into a "working copy" directory. With git, your working copy is the repository.只需在包含要跟踪的文件的目录中运行
git init
.Simply run
git init
in the directory which contains the files you wish to track.例如
cd ~/code/project001/ git init
这会在当前目录中创建一个
.git
(隐藏)文件夹.This creates a
.git
(hidden) folder in the current directory.要创建一个新项目,请使用附加参数(要创建的目录的名称)运行
git init
:To make a new project, run
git init
with an additional argument (the name of the directory to be created):git init project002 (This is equivalent to: mkdir project002 && cd project002 && git init)
要检查当前当前路径是否在 git 存储库中,只需运行
git status
- 如果它不是存储库,它将报告fatal: Not a git repository"To check if the current current path is within a git repository, simply run
git status
- if it's not a repository, it will report "fatal: Not a git repository"您也可以列出
.git
目录,并检查它是否包含类似于以下内容的文件/目录:You could also list the
.git
directory, and check it contains files/directories similar to the following:$ ls .git HEAD config hooks/ objects/ branches/ description info/ refs/
如果你想de-git"一个存储库(您希望停止使用 git 来跟踪该项目).只需删除存储库基础级别的
.git
目录.cd ~/code/project001/ rm -rf .git/
警告:这会破坏所有修订历史,所有你的标签,一切git已经完成的事情.它不会接触电流"文件(您当前可以看到的文件),但之前的更改、删除的文件等将无法恢复!
Caution: This will destroy all revision history, all your tags, everything git has done. It will not touch the "current" files (the files you can currently see), but previous changes, deleted files and so on will be unrecoverable!
这篇关于Git 初学者:权威实用指南的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!