Git初学者指南:权威实用指南
好的,看了之后,我决定跳到最后,继续 所以我需要的是一本Git的初学者实用指南。“初学者”被定义为知道如何处理他们的编译器,在某种程度上理解a是什么,并且在没有很好理解的情况下接触过源代码管理的人 “实用”被定义为这个人不想深入了解Git在后台做什么,甚至不关心(或知道)它是分布式的。您的回答可能暗示了这些可能性,但请尽量针对那些希望在“服务器”上保留“主”存储库并进行备份和安全的初学者,并将其本地存储库仅视为“客户端”资源 因此: 安装/设置Git初学者指南:权威实用指南,git,version-control,Git,Version Control,好的,看了之后,我决定跳到最后,继续 所以我需要的是一本Git的初学者实用指南。“初学者”被定义为知道如何处理他们的编译器,在某种程度上理解a是什么,并且在没有很好理解的情况下接触过源代码管理的人 “实用”被定义为这个人不想深入了解Git在后台做什么,甚至不关心(或知道)它是分布式的。您的回答可能暗示了这些可能性,但请尽量针对那些希望在“服务器”上保留“主”存储库并进行备份和安全的初学者,并将其本地存储库仅视为“客户端”资源 因此: 安装/设置 如何设置Git?试着涵盖Linux、Windo
- 如何设置Git?试着涵盖Linux、Windows、Mac,想想“客户机/服务器”的思维方式。
- 如何处理二进制文件(例如visio文档或编译器环境)
- 如何合并“同时”更改的文件
- 你如何拉一个特定的“释放”
- 如何解决冲突并完成合并
- 如何将一个分支的部分合并到另一个分支中
- 描述并链接到一个好的GUI、IDE插件等,使Git成为一个非命令行资源,但请列出它的局限性和优点。
- -跨平台,包括Git
- -Git附带的跨平台历史查看器
- -Mac OS X
- -Mac OS X历史查看器
- -跨平台、商业、测试版
- -Linux控制台GUI
- -适用于Windows、Linux的GUI
- -适用于Windows的软件包,包括友好的GUI
- 初学者还应该知道其他一些常见的任务吗?
- 如何有效地将subversion存储库设置为源代码管理源
- (及)
我会不时地浏览这些条目,并“整理”它们,使它们具有一致的外观/感觉,并且很容易扫描列表-请随意遵循简单的“标题-简要说明-说明列表-获取信息和额外信息”模板。我还将链接到上面项目符号列表中的条目,以便以后很容易找到它们。好吧,尽管你要求我们不要“简单地”链接到其他资源,但当已经存在一个社区增长(并且不断增长)的资源时,这是非常愚蠢的,它确实非常好:社区。说真的,一个问题中的这20多个问题绝不会简洁一致。Git社区手册以HTML和PDF两种格式提供,它以清晰、格式良好、经过同行评审的答案回答了您的许多问题,并且其格式允许您直接跳到手头的问题
唉,如果我的帖子真的让你心烦,那我就把它删除。就这么说吧。为什么还要另一个怎么做?网上有很多很好的网站,比如说最适合开始的网站。它有很好的链接,包括一个人可以贡献的链接(托管在GitHub上),它非常适合这个集体任务 在stackoverflow上,我真的希望看到你最喜欢的技巧 我最近才发现的是
git stash
,解释道,它可以让您保存当前的工作并转到另一个分支机构
编辑:与上一篇文章一样,如果你真的喜欢stackoverlow格式,将文章作为wiki,我将删除此答案提交更改
编辑文件后,需要将更改提交到git。当您执行此命令时,它将请求提交消息——这只是一个简单的文本,告诉每个人您所做的更改
$ git commit source/main.c
将提交目录中的main.c文件。/source/
$ git commit -a # the -a flag pulls in all modified files
将提交所有更改的文件(但不是新文件,这些文件需要使用git add添加到索引中)。如果您只想提交某些文件,那么首先需要使用git add将它们暂存,然后在不使用-a标志的情况下提交
提交只会更改本地存储库,而不会更改远程存储库。如果要将提交发送到远程存储库,则需要执行推送
$ git push <remote> <branch> # push new commits to the <branch> on the <remote> repository
$git push#将新提交推送到存储库上的
对于来自CVS或SVN的人来说,这是一个变化,因为提交到中央存储库现在需要两个步骤。是您所需要的全部。保证不退还你的钱 如何将其配置为忽略文件:
让git忽略您不希望它跟踪的文件的功能非常有用
要忽略一个文件或一组文件,请提供一个模式。git的模式语法相当简单,但功能强大。它适用于我将在下面提到的所有三个不同的文件
- 空行不忽略任何文件,通常用作分隔符
- 以#开头的行用作注释李>
- 《坚强》杂志
- 例如:模式:*.[oa]将忽略存储库中以.o或.a结尾的所有文件(对象和归档文件)
$ git status
[...]
# Untracked files:
[...]
# Documentation/foo.html
# Documentation/gitignore.html
# file.o
# lib.a
# src/internal.o
[...]
$ cat .git/info/exclude
# ignore objects and archives, anywhere in the tree.
*.[oa]
$ cat Documentation/.gitignore
# ignore generated html files,
*.html
# except foo.html which is maintained by hand
!foo.html
$ git status
[...]
# Untracked files:
[...]
# Documentation/foo.html
[...]
git add .gitignore
core.excludesfile = ~/.gitglobalignore
cd ~/code/project001/
git init
git init project002
(This is equivalent to: mkdir project002 && cd project002 && git init)
$ ls .git
HEAD config hooks/ objects/
branches/ description info/ refs/
cd ~/code/project001/
rm -rf .git/
git tag -a thetagname
git tag -a 0.1
git tag -a 2.6.1-rc1 -m 'Released on 01/02/03'
$ git tag -a thetagname # and enter a message, or use -m 'My tag annotation'
$ git tag -l
thetagname
$ git tag -d thetagname
Deleted tag 'thetagname'
$ git tag
[no output]
git tag [tag name] [revision SHA1 hash]
git tag 1.1.1 81b15a68c6c3e71f72e766931df4e6499990385b
git tag mytagwithmsg -a -m 'This is a tag, with message'
$ git tag -l -n1
mytagwithmsg This is a tag, with message
apt-get install tig
apt-get install git-core
sudo port install git-core+bash_completion+doc
fink install git
brew install git
yum install git
./configure && make && sudo make install
./configure --prefix=/usr/local/gitpath
make
sudo make install
export PATH="${PATH}:/usr/local/bin/gitpath/bin/"
# Revert to a previous commit by hash:
git-reset --hard <hash>
# Revert to previous commit:
git-reset --hard HEAD^
git clone user@host.com:/dir/to/repo
git branch <branch-name>
git branch
git checkout <branch-name>
git checkout -b <branch-name>
git branch -d <branch-name>
git stash
git stash branch <branch-name>
git merge master
git diff
$ git pull <remote> <branch> # fetches the code and merges it into
# your working directory
$ git fetch <remote> <branch> # fetches the code but does not merge
# it into your working directory
$ git pull --tag <remote> <branch> # same as above but fetch tags as well
$ git fetch --tag <remote> <branch> # you get the idea
# list remote branches
git branch -r
# start tracking one remote branch
git branch --track some_branch origin/some_branch
# change to the branch locally
git checkout some_branch
# make changes and commit them locally
....
# push your changes to the remote repository:
git push
# create a new branch locally
git branch name_of_branch
git checkout name_of_branch
# edit/add/remove files
# ...
# Commit your changes locally
git add fileName
git commit -m Message
# push changes and new branch to remote repository:
git push origin name_of_branch:name_of_branch
$ git diff <commit1> <commit2> <file_name>
$ git diff --staged <file_name>
$ git diff <file_name>
git log -- filename
mkdir /your/share/folder/project.git
cd /your/share/folder/project.git
newgrp yourteamgroup # if necessary
git init --bare --shared
cd your/local/workspace/project
git remote add origin /your/share/folder/project.git
git push origin master
cd your/local/workspace
git clone /your/share/folder/project.git
cd your/local/workspace/project
git remote add origin user@server:/path/to/project.git
git push origin master
cd your/local/workspace
git clone user@server:/path/to/project.git
git push origin :mybranchname