赞
踩
Git是世界上最先进的分布式版本控制系统,克隆一个项目的速度非常快。每个开发都可以从master上克隆一个本地版本库,就算没有网络,也可以提交代码到本地仓库、查看log、创建项目分支等等(ps小编也是下了很大的勇气才来写git的文章,毕竟需要储备和查找很多知识点,哈哈哈需要鼓励咯)
2.1 git的下载地址 : https://git-scm.com/downloads
2.2 选择所需要的版本
2.3下载后打开安装程序
2.4 选择自己的安装位置
2.5 选择自己需要安装的部件
2.6 默认选择就好
2.7 默认选择就好
2.8 进入安装最后界面
按照文件是否已加入版本控制来划分:Tracked(已跟踪)和Untracked(未跟踪)
细分状态说明 :
新建一个文件,该文件处于 Untracked 状态;
2.通过git add命令添加到缓存区,此时文件处于Tracked状态又或者说
此时这个文件已经被版本控制系统所跟踪,而且他处于Staged(暂存)状态;
3.通过git commit命令把暂存区的文件提交提交到本地仓库,此时文件
处于Unmodified(未修改)状态;
4.此时如果去编辑这个文件,文件又会变成Modified(修改)状态;
4.1 git init 初始化一个depository
4.2 设置用户名和邮箱
git config --global user.name “用户名” # 设置用户名
git config --global user.email “用户邮箱” #设置邮箱
4.3 添加.gitignore文件配置
(也可以自己定义)示例模板 :
# 忽略所有以 .c结尾的文件
*.c
# 但是 stream.c 会被git追踪
!stream.c
# 只忽略当前文件夹下的TODO文件, 不包括其他文件夹下的TODO例如: subdir/TODO
/TODO
# 忽略所有在build文件夹下的文件
build/
# 忽略 doc/notes.txt, 但不包括多层下.txt例如: doc/server/arch.txt
doc/*.txt
# 忽略所有在doc目录下的.pdf文件
doc/**/*.pdf
4.4 把文件java.txt加入到暂存区,并且设置忽略文件
**可以看到test.c已经被忽略提交
git add java.txt
4.5 查看文件的状态
git status
4.6 把暂存区的文件提提交到本体仓库
git commit -m ‘第一次提交’
4.7 查看提交日志
git log
6.1 本地仓库和远程仓库建立连接
git remote add origin 远程git仓库地址
6.2提交文件当git远程仓库
git push -u origin master(第一提交的时候需要加 -u,后面就不需要了,然后输入账号密码)
6.3提交
git push origin master
6.4 可能出现的错误
出现这种情况,可先更新 git pull --rebase origin master
7.1 ssh-keygen -t rsa -b 4096 -C “your_email@example.com” 先生成秘钥
7.2登录github设置ssh keys
7.3 按照要求填空
git的专有名词解释
Git术语 | 解释 |
---|---|
branch | A “branch” is an active line of development. The most recent commit on a branch is referred to as the tip of that branch. The tip of the branch is referenced by a branch head, which moves forward as additional development is done on the branch. A single Git repository can track an arbitrary number of branches, but your working tree is associated with just one of them (the “current” or “checked out” branch), and HEAD points to that branch. |
cherry-picking | In SCM jargon, “cherry pick” means to choose a subset of changes out of a series of changes (typically commits) and record them as a new series of changes on top of a different codebase. In Git, this is performed by the “git cherry-pick” command to extract the change introduced by an existing commit and to record it based on the tip of the current branch as a new commit. |
clean | A working tree is clean, if it corresponds to the revision referenced by the current head. Also see “dirty”. |
commit | As a noun: A single point in the Git history; the entire history of a project is represented as a set of interrelated commits. The word “commit” is often used by Git in the same places other revision control systems use the words “revision” or “version”. Also used as a short hand for commit object.As a verb: The action of storing a new snapshot of the project’s state in the Git history, by creating a new commit representing the current state of the index and advancing HEAD to point at the new commit. |
dirty | A working tree is said to be “dirty” if it contains modifications which have not been committed to the current branch. |
fast-forward | A fast-forward is a special type of merge where you have a revision and you are “merging” another branch’s changes that happen to be a descendant of what you have. In such a case, you do not make a new merge commit but instead just update to his revision. This will happen frequently on a remote-tracking branch of a remote repository. |
fetch | Fetching a branch means to get the branch’s head ref from a remote repository, to find out which objects are missing from the local object database, and to get them, too. See also git-fetch(1). |
gitfile | A plain file .git at the root of a working tree that points at the directory that is the real repository. |
HEAD | The current branch. In more detail: Your working tree is normally derived from the state of the tree referred to by HEAD. HEAD is a reference to one of the heads in your repository, except when using a detached HEAD, in which case it directly references an arbitrary commit. |
master | The default development branch. Whenever you create a Git repository, a branch named “master” is created, and becomes the active branch. In most cases, this contains the local development, though that is purely by convention and is not required. |
merge | As a verb: To bring the contents of another branch (possibly from an external repository) into the current branch. In the case where the merged-in branch is from a different repository, this is done by first fetching the remote branch and then merging the result into the current branch. This combination of fetch and merge operations is called a pull. Merging is performed by an automatic process that identifies changes made since the branches diverged, and then applies all those changes together. In cases where changes conflict, manual intervention may be required to complete the merge.As a noun: unless it is a fast-forward, a successful merge results in the creation of a new commit representing the result of the merge, and having as parents the tips of the merged branches. This commit is referred to as a “merge commit”, or sometimes just a “merge”. |
origin | The default upstream repository. Most projects have at least one upstream project which they track. By default origin is used for that purpose. New upstream updates will be fetched into remote-tracking branches named origin/name-of-upstream-branch, which you can see using git branch -r. |
pull | Pulling a branch means to fetch it and merge it. See also git-pull(1). |
push | Pushing a branch means to get the branch’s head ref from a remote repository, find out if it is a direct ancestor to the branch’s local head ref, and in that case, putting all objects, which are reachable from the local head ref, and which are missing from the remote repository, into the remote object database, and updating the remote head ref. If the remote head is not an ancestor to the local head, the push fails. |
rebase | To reapply a series of changes from a branch to a different base, and reset the head of that branch to the result. |
repository | A collection of refs together with an object database containing all objects which are reachable from the refs, possibly accompanied by meta data from one or more porcelains. A repository can share an object database with other repositories via alternates mechanism. |
resolve | The action of fixing up manually what a failed automatic merge left behind. |
作者:pony_hjc
来源:CSDN
QQ :154069491
原文:https://blog.csdn.net/qq_41513129/article/details/108609552
版权声明:本文为博主原创文章,转载请附上博文链接!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。