首页 > 代码库 > Git操作

Git操作

  • 创建版本库
zhangliuningdeMacBook-Pro:WorkPath sherry$ mkdir GitHomeTestzhangliuningdeMacBook-Pro:WorkPath sherry$ cd GitHomeTest/zhangliuningdeMacBook-Pro:GitHomeTest sherry$ git initInitialized empty Git repository in /Users/sherry/WorkPath/GitHomeTest/.git/

或者直接

git init ./GitHomeTest 也行,会自动创建目录,要求Git版本在1.6.5以后

 

  • 将文件添加到版本库
zhangliuningdeMacBook-Pro:GitHomeTest sherry$ git add welcome.txt 
  • 将添加到版本库中的文件进行提交
zhangliuningdeMacBook-Pro:GitHomeTest sherry$ git commit -m "添加一个测试文件"[master (root-commit) 9a17716] 添加一个测试文件 1 file changed, 1 insertion(+) create mode 100644 welcome.txt

 

  • 查看Git版本库状态
zhangliuningdeMacBook-Pro:GitHomeTest sherry$ git statusOn branch masternothing to commit, working directory clean

 

  • 从版本库中拷贝
git clone 目录

 

Git操作