git使用
来源:互联网 发布:各国人工智能发展现状 编辑:程序博客网 时间:2024/05/20 17:25
git使用:
1.安装:
sudo apt-get install git-core
2.配置:
在.gitconfig文件中设置git的全局配置,
可以通过如下命令配置git的用户名和email(这两个是必须的)
git config --global user.name "keke"
git config --global user.email "1794036012@qq.com"
这些命令将写入当前用户根目录下的.gitconfig文件中:如/home/keke/.gitconfig
高亮显示:git config --global color.status auto
git config --global color.branch auto
获取git的配置信息:git config --list
3.开始操作git:
进入需要备份的文件夹的根目录,执行:
git init(初始化本地git存储区)
git add .(add all 文件和目录到git存储区)
git commit -m “initial commit”(提交文件到本地存储区)
git log(显示log文件,已经提交版本的作者信息等和commit id)
4.diff跟commit:
git diff(查看做了那些更改)
git commit -a -m "these are new changes"(提交更改到存储区)
git status(展示git现在的状态,修改了什么文件还没有提交)
git add . && git commit -m "new changes"(add all文件和目录到git存储区 并且 提交文件)
5. gitk的使用:
安装gitk: apt-get install gitk
gitk --all(图形化界面 列出所有的提交信息)
6.删除文件:
rm 一个文件
git add -a -m "file has removed" 或者
git add -A . && git commit -m "file has removed"
7.remote repositories(远端仓库)
这个仓库可以存储在本地或者网络上,
git clone --bare . ../remote-repository.git(存储在本地文件系统上)
推送:如果现在源文件做了一些改变
git commit -a -m "some changes"
git push ../remote-repository.git
为远端仓库添加一个短名称:
git remote add origin ../remote-repository.git(引用名称为origin)
git commit -a -m "a test for origin"
git push origin(相当于 git push ../remote-repository.git)
git remote(显示已有的远端仓库)
克隆仓库:
git clone ../remote-repository.git . (在一个新目录下,)
8.pull拉取更改:
在执行:git remote add origin ../remote-repository.git 使origin为远端仓库的别名之后
现在repo02中更新origin,然后进入repo01 pull最新的版本
cd ~/repo02
git commit -a -m "a change"
git push origin
cd ~/repo01
git pull ../remote-repository.git/
9.丢弃文件:
创建了一个文件发现不需要:touch test 04
git clean -n(显示将删除什么)
git clean -f(执行删除)
- 【git】VS2015使用Git
- 【GIT】 git rebase 使用
- 【Git】Git客户端使用
- 使用git
- git使用
- Git使用
- Git使用
- git 使用
- Git使用
- git使用
- git使用
- git 使用
- git 使用
- git 使用
- git 使用
- git 使用
- Git使用
- git 使用
- Android四大组件之Activity(几种FLAG加载模式)
- mysql 5.7的多源复制搭建
- Python lower()方法 #把字符串转换成小写
- Android依我见之滑动冲突处理
- CCF-201412-2 Z字形扫描
- git使用
- C#前期小总结
- debian中默认不存在sudo命令解决方法
- Java网络编程(三)
- CORDIC算法(一):圆周旋转模式下计算三角函数和模值
- C#设计模式学习小结之六 外观模式
- hadoop2.x_64bit编译安装
- Java学习日记_17:面向对象之封装的概述。07.04
- BZOJ4003 [JLOI2015]城池攻占 解题报告