腾讯工蜂:

http://git.code.tencent.com

登录-->>创建项目-->>获取仓库路径

https://git.code.tencent.com/dangzhengtao/MyAppTest.git

Git官网下载: https://git-scm.com/downloads

Git是目前世界上最先进的分布式版本控制系统

Workspace:工作区

Index / Stage:暂存区

Repository:仓库区(或本地仓库)

Remote:远程仓库

安装完成后打开Git Bash

git config --global user.name "用户名"

git config --global user.email "邮箱"

注意:git config --global 参数,有了这个参数,表示你这台机器上所有的Git仓库都会使用这个配置,当然你也可以对某个仓库指定的不同的用户名和邮箱。

输入:git init  初始化git仓库  本地目录文件夹下会生成.git文件夹

输入: git add.(命令里有个点)将当前目录所有文件标记为需要入库的新文件  (如果是更新单个文件 则需要输入文件名)

输入:git status  查看当前仓库状态

本地代码推送到远程git仓库。

输入:git remote add origin https://git.qcloud.com/cbuttonst/test.git 添加远程仓库地址。

如果add的url不小心输错了,可以使用:git remote set-url origin https://xxx 重新设置成新的url。

输入:git pull --rebase origin master  这时会提示你输入用户名(腾讯工蜂中的用户名),回车之后会弹出一个密码输入框(密码也是注册账号过程中你自己填写的)。这一步时将远程仓库文件拉到本地仓库,更新本地仓库。会出现下列信息。

输入命令:git push -u origin master 推送本地代码到远程git仓库,

  1.  

初始化

  1. # 在当前目录新建一个Git代码库
  2. $ git init
  3. # 新建一个目录,将其初始化为Git代码库
  4. $ git init git_test
  5. # 下载一个项目和它的整个代码历史
  6. $ git clone http://git.code.oa.com/jaelintu/git_test

增加/删除文件

  1. # 添加指定文件到暂存区
  2. $ git add file1 file2...
  3. # 添加指定目录到暂存区,包括子目录
  4. $ git add dir
  5. # 添加当前目录的所有文件到暂存区
  6. $ git add .
  7. # 添加每个变化前,都会要求确认
  8. # 对于同一个文件的多处变化,可以实现分次提交
  9. $ git add -p
  10. # 删除工作区文件,并且将这次删除放入暂存区
  11. $ git rm file1 file2 ...

代码提交

  1. # 提交暂存区到仓库区
  2. $ git commit -m "message"
  3. # 提交暂存区的指定文件到仓库区
  4. $ git commit file1 file2 ... -m "message"
  5. # 提交工作区自上次commit之后的变化,直接到仓库区
  6. $ git commit -a
  7. # 提交时显示所有diff信息
  8. $ git commit -v
  9. # 使用一次新的commit,替代上一次提交
  10. # 如果代码没有任何新变化,则用来改写上一次commit的提交信息
  11. $ git commit --amend -m "message"
  12. # 重做上一次commit,并包括指定文件的新变化
  13. $ git commit --amend file1 file2 ...

分支

  1. # 列出所有本地分支
  2. $ git branch
  3. # 列出所有远程分支
  4. $ git branch -r
  5. # 列出所有本地分支和远程分支
  6. $ git branch -a
  7. # 新建一个分支,但依然停留在当前分支
  8. $ git branch name
  9. # 新建一个分支,并切换到该分支
  10. $ git checkout -b branch
  11. # 新建一个分支,指向指定commit
  12. $ git branch name commit_SHA
  13. # 新建一个分支,与指定的远程分支建立追踪关系
  14. $ git branch --track name orgin/name
  15. # 切换到指定分支,并更新工作区
  16. $ git checkout name
  17. # 切换到上一个分支
  18. $ git checkout -
  19. # 建立追踪关系,在现有分支与指定的远程分支之间
  20. $ git branch --set-upstream name origin/name
  21. # 合并指定分支到当前分支
  22. $ git merge branch-name
  23. # 选择一个commit,合并进当前分支
  24. $ git cherry-pick commit_SHA
  25. # 删除分支
  26. $ git branch -d branch-name
  27. # 删除远程分支
  28. $ git push origin --delete branch-name
  29. $ git branch -dr remote/branch

tags

  1. # 列出所有tag
  2. $ git tag
  3. # 新建一个tag在当前commit
  4. $ git tag tag-name
  5. # 新建一个tag在指定commit
  6. $ git tag tag-name commit-SHA
  7. # 删除本地tag
  8. $ git tag -d tag-name
  9. # 删除远程tag
  10. $ git push origin :refs/tags/tag-Name
  11. # 查看tag信息
  12. $ git show tag-name
  13. # 提交指定tag
  14. $ git push origin tag-name
  15. # 提交所有tag
  16. $ git push origin --tags
  17. # 新建一个分支,指向某个tag
  18. $ git checkout -b branch-name tag-name

查看信息

  1. # 显示有变更的文件
  2. $ git status
  3. # 显示当前分支的版本历史
  4. $ git log
  5. # 显示commit历史,以及每次commit发生变更的文件
  6. $ git log --stat
  7. # 搜索提交历史,根据关键词
  8. $ git log -S [keyword]
  9. # 显示某个commit之后的所有变动
  10. $ git log (tag-name||commit-SHA) HEAD
  11. # 显示某个文件的版本历史,包括文件改名
  12. $ git log --follow file
  13. $ git whatchanged file
  14. # 显示指定文件相关的每一次diff
  15. $ git log -p file
  16. # 显示过去5次提交
  17. $ git log -5 --pretty --oneline
  18. # 显示所有提交过的用户,按提交次数排序
  19. $ git shortlog -sn
  20. # 显示指定文件是什么人在什么时间修改过
  21. $ git blame file
  22. # 显示暂存区和工作区的代码差异
  23. $ git diff
  24. # 显示暂存区和上一个commit的差异
  25. $ git diff --cached file
  26. # 显示工作区与当前分支最新commit之间的差异
  27. $ git diff HEAD
  28. # 显示两次提交之间的差异
  29. $ git diff [first-branch]...[second-branch]
  30. # 显示今天你写了多少行代码
  31. $ git diff --shortstat "@{0 day ago}"
  32. # 显示某次提交的元数据和内容变化
  33. $ git show commit-SHA
  34. # 显示某次提交发生变化的文件
  35. $ git show --name-only commit-SHA
  36. # 显示某次提交时,某个文件的内容
  37. $ git show commit-SHA:filename
  38. # 显示当前分支的最近几次提交
  39. $ git reflog
  40. # 从本地master拉取代码更新当前分支:branch 一般为master
  41. $ git rebase branch-name

远程同步

  1. # 下载远程仓库的所有变动
  2. $ git fetch origin
  3. # 显示所有远程仓库
  4. $ git remote -v
  5. # 显示某个远程仓库的信息
  6. $ git remote show origin
  7. # 增加一个新的远程仓库,并命名
  8. $ git remote add shortname url
  9. # 取回远程仓库的变化,并与本地分支合并
  10. $ git pull origin branch-name
  11. # 上传本地指定分支到远程仓库
  12. $ git push origin branch-name
  13. # 强行推送当前分支到远程仓库,即使有冲突
  14. $ git push origin --force
  15. # 推送所有分支到远程仓库
  16. $ git push origin --all

撤销

  1. # 恢复暂存区的指定文件到工作区
  2. $ git checkout file
  3. # 恢复某个commit的指定文件到暂存区和工作区
  4. $ git checkout commit-SHA file
  5. # 恢复暂存区的所有文件到工作区
  6. $ git checkout .
  7. # 重置暂存区的指定文件,与上一次commit保持一致,但工作区不变
  8. $ git reset file
  9. # 重置暂存区与工作区,与上一次commit保持一致
  10. $ git reset --hard
  11. # 重置当前分支的指针为指定commit,同时重置暂存区,但工作区不变
  12. $ git reset commit-SHA
  13. # 重置当前分支的HEAD为指定commit,同时重置暂存区和工作区,与指定commit一致
  14. $ git reset --hard commit-SHA
  15. # 重置当前HEAD为指定commit,但保持暂存区和工作区不变
  16. $ git reset --keep commit-SHA
  17. # 新建一个commit,用来撤销指定commit
  18. # 后者的所有变化都将被前者抵消,并且应用到当前分支
  19. $ git revert commit-SHA
  20. # 暂时将未提交的变化移除,稍后再移入
  21. $ git stash
  22. $ git stash pop

冲突解决

rebase过程中,也许会出现冲突(conflict)

  • git会停止rebase,需要解决冲突
  • 解决完,使用git add添加冲突的文件,更新暂存区
  • git rebase --continue继续剩下的rebase
  • git rebase --abort终止rebase行为,并且feature会回到rebase开始之前的状态
  1. $ git rebase develop
  2. CONFLICT (content): Rebase conflict in readme.txt
  3. Automatic rebase failed; fix conflicts and then commit the result.
  4. $ git status
  5. On branch feature
  6. You have unmerged paths.
  7. (fix conflicts and run "git rebase --continue")
  8. (use "git merge --abort" to abort the merge)
  9. Unmerged paths:
  10. (use "git add <file>..." to mark resolution)
  11. both modified: readme.txt
  12. no changes added to commit (use "git add" and/or "git commit -a")

查看readme.md 内容

  1. Git tracks changes of files.
  2. <<<<<<< HEAD
  3. Creating a new branch is quick & simple.
  4. =======
  5. Creating a new branch is quick AND simple.
  6. >>>>>>> feature

选择保留HEAD或者feature的版本

  1. Git tracks changes of files.
  2. Creating a new branch is quick AND simple.

在提交:

  1. $ git add readme.md
  2. $ git rebase --contine

推荐的Git GUI工具

1. Source Tree(号称最好用):特色支持git flow,一键创建工作流

  • 免费功能
  • 强大:无论你是新手还是重度用户,SourceTree 都会让你觉得很顺手。对于非常重度用户,Source Tree还支持自定义脚本的执行
  • 同时支持 Windows 和 Mac 操作系统
  • 同时支持 Git 和 Mercurial 两种 VCS
  • 内置GitHub, BitBucket 和 Stash 的支持:直接绑定帐号即可操作远程repo

    2. Tortoise git:文件的右键菜单很容易上手

  • 免费
  • 只支持Windows:与文件管理器良好集成
  • 中文界面
  • 与Tortoise SVN相同的体验
  1.  

Git操作记录、腾讯工蜂的更多相关文章

  1. Git操作记录

    记录一些用过的操作 增加远程推送分支 git remote add orgin http://xxxxx.git 直接新建本地分支,将远程分支提取出来. git checkout -t origin/ ...

  2. 个人常用Git操作记录

    本地分支与远程分支建立联系 Git - 新建本地分支与远程分支关联问题 查看本地分支与远程分支关系: git branch -vv 当前分支与远程分支建立关系: git branch --set-up ...

  3. git操作记录(如何回退到某个历史版本,如何提交部分文件等方法)

    当前项目使用git管理代码,在使用的过程中会遇到一些问题,这里记录下 1.合并代码后 在合并组员的代码后会出现下面的界面,开始的时候都会关闭,重新打开,乐此不疲到忍无可忍 解决方法: 出现这种界面是要 ...

  4. jenkins中通过git发版操作记录

    之前说到的jenkins自动化构建发版是通过svn方式,今天这里介绍下通过git方式发本的操作记录. 一.不管是通过svn发版还是git发版,都要首先下载svn或git插件.登陆jenkins,依次点 ...

  5. 腾讯工蜂Git关联Jenkins Hooks

    现在国内外Git平台非常多,最近维护的腾讯工蜂免费公网版本git.code.tencent.com,免注册(建议使用微信登录,舒服)即可使用私有仓库.对小型团队体验还不错,如果要关联Jenkins进行 ...

  6. centos下升级git版本的操作记录

    在使用git pull.git push.git clone的时候,或者在使用jenkins发版的时候,可能会报类似如下的错误: error: The requested URL returned e ...

  7. centos6下升级git版本的操作记录

    编译go_ethereum的时候出现了错误 然后发现是自己的git没有升级成功  因为编译需要高版本的git版本  所以会编译不成功  之后执行 root@uatjenkins01 ~]# git - ...

  8. git reflog查看所有操作记录

    git reflog 可以查看所有分支的所有操作记录(包括(包括commit和reset的操作),包括已经被删除的commit记录,git log则不能察看已经删除了的commit记录 具体一个例子, ...

  9. 转:centos下升级git版本的操作记录

    https://www.cnblogs.com/kevingrace/p/8252517.html 在使用git pull.git push.git clone的时候,或者在使用jenkins发版的时 ...

随机推荐

  1. Swagger2 模拟请求头

    前几天开发项目的时候,使用了Restful风格的接口.进行开发的时候,模拟请求头,带Token的时候遇到了一些问题.因为Api接口使用Swagger2进行搭建,所以找到了Swagger2 模拟head ...

  2. python 操作excle 之第三方库 openpyxl学习

    目录 python 操作excle 之第三方库 openpyxl学习 安装 pip install openpyxl 英文文档链接 : 点击这里~ 1,定位excel 2,读取excle中的内容 3, ...

  3. 四十一.redis主从复制 RDB/AOF持久化 数据类型

    把redis集群里的主机 恢复为独立的redis服务器(51-58) ]# redis-cli  -h 192.168.4.51 -p 6351 shutdown ]# rm -rf /var/lib ...

  4. Bzoj 1280: Emmy卖猪pigs

    1280: Emmy卖猪pigs Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 279  Solved: 182[Submit][Status][Dis ...

  5. 搭建自己的博客(十三):为博客后台添加ckeditor富文本编辑器

    使用django默认的编辑器感觉功能太少了,所以集成一下富文本编辑器. 1.安装和使用 (1).安装 pip install django-ckeditor (2).注册应用 在django的sett ...

  6. Unity使用Xcode将项目打包成IPA

    https://blog.csdn.net/Superficialtise/article/details/79699813 Unity是个开放性的平台,打包时也可以选择多种打包类型,几乎包含了所有的 ...

  7. 服务器之poll

    poll服务器方法采用将监听端口用数组存放起来,这样就不需要轮询的监听整个文件描述符了 #include <poll.h> int poll(struct pollfd *fds, nfd ...

  8. 修改rabbitmq web-UI端口号

    一.拷贝配置文件 [root@test03 ~]# cd /usr/share/doc/rabbitmq-server-3.6.15/ [root@test03 rabbitmq-server-3.6 ...

  9. Linux fdisk命令创建扩展分区过程

    [root@localhost ~]# fdisk /dev/sdb …省略部分输出… Command (m for help): n #新建立分区 Command action e extended ...

  10. qt 创建程序目录

    voidinitDir() { QStringuserFilePath=QStandardPaths::writableLocation(QStandardPaths::DocumentsLocati ...