您的位置:首页 > 其它

GIT使用笔记

2019-06-06 16:35 246 查看

git的第一步是配置自己的信息:

配置个人的用户名和email:

$ git config --global user.name "asber"
$ git config --global user.email 1402051732@qq.com

若要深入了解GIT 可以看一看Git 工作区、暂存区和版本库

git的工作流程:

  1. 克隆 Git 资源作为工作目录。
  2. 在克隆的资源上添加或修改文件。
  3. 如果其他人修改了,你可以更新资源。
  4. 在提交前查看修改。
  5. 提交修改。
  6. 在修改完成后,如果发现错误,可以撤回提交并再次修改并提交。

如果要兴建新的工程,则到网页上去创建

这样就新建成功了

我们复制其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
然后会出现提示框让你输入用户名和密码

我这里出现了一个报错:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: