GIT使用笔记
git的第一步是配置自己的信息:
配置个人的用户名和email:
$ git config --global user.name "asber"
$ git config --global user.email 1402051732@qq.com
若要深入了解GIT 可以看一看Git 工作区、暂存区和版本库
git的工作流程:
- 克隆 Git 资源作为工作目录。
- 在克隆的资源上添加或修改文件。
- 如果其他人修改了,你可以更新资源。
- 在提交前查看修改。
- 提交修改。
- 在修改完成后,如果发现错误,可以撤回提交并再次修改并提交。
如果要兴建新的工程,则到网页上去创建
这样就新建成功了
我们复制其URL
https://github.com/huoganji/gittest.git
第一步:在对应的文件夹下打开git bash
- 创建新仓库:$git init :Initialized empty Git repository in C:/Users/14020/Documents/python/.git/ [创建成功]
初始化一个Git仓库命令。使用Git的第一个命令,使用之后会生成一个.git的目录,包含了所有的元数据(git是以元数据的格式存储文件的)PS:ls -a可以看到隐藏文件
也可以使用我们指定的newrepo目录来作为Git的本地仓库
- git init newrepo:Initialized empty Git repository in C:/Users/14020/Documents/python/newrepo/.git/
这个.git的目录存放Git需要的数据和资源
第二步:(如果已经有工程了)
如果说Git仓库的文件夹新文件需要上传(纳入版本控制)
那么先要用git add告诉Git对文件进行跟踪,然后提交:
$ vim //我vim了一个introduce.txt
14020@DESKTOP-7LT3RI3 MINGW64 ~/Documents/python (master)
$ ls
introduce.txt newrepo/14020@DESKTOP-7LT3RI3 MINGW64 ~/Documents/python (master)
$ git add *.txt //将所有的.txt文件进行跟踪
warning: LF will be replaced by CRLF in introduce.txt.
The file will have its original line endings in your working directory.14020@DESKTOP-7LT3RI3 MINGW64 ~/Documents/python (master)
$ git commit -m 'myfirstdemo' //提交 'myfirstdemo'是初始化的项目版本
[master (root-commit) 72502e1] myfirstdemo
warning: LF will be replaced by CRLF in introduce.txt.
The file will have its original line endings in your working directory.
2 files changed, 2 insertions(+)
create mode 100644 cxq.txt
create mode 100644 introduce.txt
git clone是从现有的Git仓库中拷贝项目<到指定的本地目录>
- git clone <repo>
- git clone <repo> <directory>
- 比如: git clone git://github.com/schacon/grit.git
- git clone git://github.com/schacon/grit.git mygrit
第二点五步:如果是新建的工程:init之后
git remote add origin http://github.com/huoganji/gittest.git
如果写错了要删除远程仓库的话:git remote rm origin
最后 将代码上传到github的仓库中
git push -u origin master
然后会出现提示框让你输入用户名和密码
我这里出现了一个报错:
- GIT使用笔记
- GIT学习笔记1--基本使用
- Git 使用笔记
- Git使用笔记
- git 使用笔记
- Git 使用笔记
- git笔记之安装使用
- Git使用笔记(二)-可视化Merge工具Meld
- git 安装使用笔记
- GIT使用笔记FOR Windows
- Windows 和 Ubuntu 下 Git 使用笔记
- GIT使用笔记
- 【Git笔记】使用技巧:命令自动补全及命令别名的配置方法
- Git使用笔记
- git 使用笔记(一)
- git使用笔记【转】
- 《版本控制之道--使用Git》笔记
- ubuntu 下git安装及使用笔记
- Emacs学习笔记(14):在Emacs中使用git
- 【Git 学习笔记】2.5 - 远程仓库的使用