首页 技术 正文
技术 2022年11月20日
0 收藏 329 点赞 2,729 浏览 2007 个字

Git的用法

Git 的也可以理解为版本控制器。版本控制器(维基的解释):维护工程蓝图的标准作法,能追踪工程蓝图从诞生一直到定案的过程。此外,版本控制也是一种软件工程技巧,借此能在软件开发的过程中,确保由不同人所编辑的同一代码文件案都得到同步。

非常适合团队开发大型项目。可以放心大胆的进行代码修改,如果出错可以回复之前提交过的任何版本(前提是你的提交比较合理),而且可以合并不同的分支中不同的版本。

Git 的下载

百度网盘(windows 64bit):http://pan.baidu.com/s/1nv2PM33

git官网:https://git-scm.com/downloads

Git 本地代码库的使用

进入你想进行同步的目录下,使用cd + [路径]的命令。或者直接进入到文件目录下,右键选择Git Bash Here/Git GUI Here。

Git的用法

创建本地代码库,使用git init命令,git会在目录下创建一个隐藏文件.git。此文件千万不能删。

Git的用法

提交代码。可以将git 作用的空间抽象为3个:工作目录(Working area),暂存区(Starging area),仓库(repository)。

工作目录就是你当前目录下的文件。

暂存区是用来暂存更改的文件的,放在工作目录和仓库中间,用来过度的。只能提交暂存区的文件,不能直接提交工作目录。

仓库保存了之前提交的所有记录,可以使用git log命令查看所有提交,而且可以回退到任意提交记录。

因为不能直接提交工作目录中更改的文件,所以必须使用git add [文件名]加入到暂存区,然后git commit提交。如果你不知道哪些文件更改了使用git status查看目前所有的更改。

Git 与 远程代码库的链接(与github的连接)

创建github账户,创建工程。Github对每一个创建的工程都会创建一个远程同步接口。通常我们使用https来提交本地保存的代码库。

Git的用法

Git的用法

使用git remote add [远程版本库名(origin)] [URL]命令,创建远程版本库连接。可以使用命令git remote来查看是否创建成功。如果创建成功显示远程版本库名。

Git的用法

Git的用法

使用git push[远程版本库名] [要推送的本地分支]命令,推送分支。

Git的用法

Git 附录

Git常用命令

start a working area (see also: git help tutorial)

clone Clone a repository into a new directory

init Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)

add Add file contents to the index

mv Move or rename a file, a directory, or a symlink

reset Reset current HEAD to the specified state

rm Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)

bisect Use binary search to find the commit that introduced a bug

grep Print lines matching a pattern

log Show commit logs

show Show various types of objects

status Show the working tree status

grow, mark and tweak your common history

branch List, create, or delete branches

checkout Switch branches or restore working tree files

commit Record changes to the repository

diff Show changes between commits, commit and working tree, etc

merge Join two or more development histories together

rebase Reapply commits on top of another base tip

tag Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)

fetch Download objects and refs from another repository

pull Fetch from and integrate with another repository or a local branch

push Update remote refs along with associated objects

下一篇: QML杂记
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,580
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918