Git的使用

来源:互联网 发布:linux 匹配文件内容 编辑:程序博客网 时间:2024/06/06 09:49

使用Git管理自己的代码

使用Git维护自己的代码,简单的使用:

  • 在码云上创建新项目(GitHub有点慢)
  • 创建本地 git 仓库
  • 将远端服务器上的仓库clone到本地
  • 新增文件并提交
  • push到远程仓库

在码云上创建新项目

新建项目

找到新建项目,然后随便新建一个

创建本地 git 仓库

1 在本地新建一个目录,然后通过Git客户端进入到该目录
2 执行命令:git init

Administrator@WIN-P1RL8B7ODIV MINGW64 /c/git$ mkdir weixxAdministrator@WIN-P1RL8B7ODIV MINGW64 /c/git$ git initInitialized empty Git repository in C:/git/.git/

如图:
这里写图片描述

将远端服务器上的仓库clone到本地

1 现在项目界面上,找到远程仓库地址
这里写图片描述

2 现在项目界面上,找到远程仓库地址
3 通过git客户端进入到本地仓库 目录下,并执行命令:
git clone https://gitee.com/weixx3/weixx.git <– 这是远程仓库地址

Administrator@WIN-P1RL8B7ODIV MINGW64 /c/git (master)$ git clone https://gitee.com/weixx3/weixx.gitCloning into 'weixx'...remote: Counting objects: 101, done.remote: Compressing objects: 100% (91/91), done.remote: Total 101 (delta 4), reused 0 (delta 0)Receiving objects: 100% (101/101), 64.51 KiB | 0 bytes/s, done.Resolving deltas: 100% (4/4), done.

如图:
这里写图片描述

新增文件并提交

1 到 本地仓库目录下 新增一个文件 change.log

  Administrator@WIN-P1RL8B7ODIV MINGW64 /c/git/weixx (master)$ lschange.log  LICENSE  pom.xml  README.md  src/  weixx.log

2 执行命令:git status

Administrator@WIN-P1RL8B7ODIV MINGW64 /c/git/weixx (master)$ git statusOn branch masterYour branch is up-to-date with 'origin/master'.Untracked files:  (use "git add <file>..." to include in what will be committed)        change.lognothing added to commit but untracked files present (use "git add" to track)

3 执行命令: git add change.log
4 执行命令: git commit 会进入如下界面 让输入 提交说明,然后:wq保存退出
这里写图片描述

这时候只是提交到了本地仓库,并没有提交到远程仓库,所以远程仓库上还没有
5 执行命令:git push

$ git pushCounting objects: 3, done.Delta compression using up to 4 threads.Compressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 276 bytes | 0 bytes/s, done.Total 3 (delta 1), reused 0 (delta 0)To https://gitee.com/weixx3/weixx.git   1da96f1..377ffcd  master -> master

这样就提交到 远程仓库了上

这里写图片描述

原创粉丝点击