git练习
git 下载地址:
http://npm.taobao.org/mirrors/git-for-windows/ 镜像地址
https://git-scm.com/download/win 官网地址
-
git commit 提交记录
-
git branch <branch_name> 建立名为branch_name的分支
-
git checkout <name>;git commit 切换分支到name,提交 或者可以使用一条命令切换分支 git checkout -b <name>
-
git merge <name> 合并代码
- git rebase <name> 合并分支
- git reset [HEAD~1] 回退一个提交记录,一般不推荐使用,大家都使用远程的话
- git revert HEAD 撤销上次操作
- git push 上传代码 git push origin master
- git pull 拉取代码 git pull origin master
创建新分支 bugFix 用 git checkout bugFix 命令切换到该分支 提交一次 用 git checkout master 切换回 master 再提交一次 用 git merge 把 bugFix 合并到 master git branch bugFix git checkout bugFix 上面2句可以修改为git checkout -b bugFix git commit git checkout master git commit git merge bugFix
新建并切换到bugFix分支 git checkout -b bugFix 提交一次 git commit 切换回master分支再提交一次 git checkout master; git commit 再次切换到bugFix分支,rebase 到master上 git checkout bugFix; git rebase master
新增文件,并提交
hxbjmy@hxbjmy-PC MINGW64 /f/test/test (hhh) $ ls 2.txt 3.txt 4.txt hxbjmy@hxbjmy-PC MINGW64 /f/test/test (hhh) $ touch 5.txt hxbjmy@hxbjmy-PC MINGW64 /f/test/test (hhh) $ git status On branch hhh Your branch is up to date with 'origin/hhh'. Untracked files: (use "git add <file>..." to include in what will be committed) 5.txt nothing added to commit but untracked files present (use "git add" to track) hxbjmy@hxbjmy-PC MINGW64 /f/test/test (hhh) $ git add 5.txt hxbjmy@hxbjmy-PC MINGW64 /f/test/test (hhh) $ git status On branch hhh Your branch is up to date with 'origin/hhh'. Changes to be committed: (use "git reset HEAD <file>..." to unstage) new file: 5.txt hxbjmy@hxbjmy-PC MINGW64 /f/test/test (hhh) $ git commit -m 'add 5.txt' [hhh db56b29] add 5.txt 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 5.txt hxbjmy@hxbjmy-PC MINGW64 /f/test/test (hhh) $ git status On branch hhh Your branch is ahead of 'origin/hhh' by 1 commit. (use "git push" to publish your local commits) nothing to commit, working tree clean hxbjmy@hxbjmy-PC MINGW64 /f/test/test (hhh) $ git push Counting objects: 2, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), done. Writing objects: 100% (2/2), 263 bytes | 263.00 KiB/s, done. Total 2 (delta 1), reused 0 (delta 0) remote: remote: 升级至腾讯云开发者平台获得更高代码仓库容量和带宽,了解详情:https://feedback.coding.net/topics/7257 To https://git.coding.net/jingxin_xinjing/test.git edc1447..db56b29 hhh -> hhh hxbjmy@hxbjmy-PC MINGW64 /f/test/test (hhh) $ git status On branch hhh Your branch is up to date with 'origin/hhh'. nothing to commit, working tree clean
git init
git status 查看当前项目下所有文的状态
git add . “.”点号表示对当前目录下的所有文件/文件夹进行跟踪
git commit -m 'test' 将文件提交到本地仓库 , -m参数是对本次的提交进行描述
git remote add origin 'git@gitcafe.com:fnngj/pyse.git' 第一次提交项目,指定本地的项目跟远程的哪个仓库建立连接
git push -u origin master 将本地的项目提交到远程仓库
git pull origin master 将远程的代码拉取到本地
git clone git://gitcafe.com/fnngj/pyse.git 克隆代码到本地