码迷,mamicode.com
首页 > 其他好文 > 详细

git常用指令(sourceTree挺香的)

时间:2020-06-09 09:41:41      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:creat   path   git log   tty   fetch   日志   git仓库   rect   make   

提交代码一般流程(不推荐使用. 泛指需要提交的文件)

  1. git add .
  2. git commit -m ‘some message‘
  3. git pull origin master
  4. git push origin master

设置用户名和密码

git config --global user.name "Your name"
git config --global user.email "email@example.com"

初始化本地git仓库

git init (on the directory wanna set as repository)
ps : commond ll -a to make sure the .git file created

查看提交日志

git log;
git log --pretty=oneline;

回滚

HEAD 是版本标记,用于版本回滚,可使用git log 查看
git reset --hard commit_id
忘记回滚版本可使用git reflog查看历史命令

撤销修改:

add 之前:git checkout -- <file_path>
add 之后:git reset HEAD <file_path> 然后 git checkout -- <file_path>
git push origin 分支名
本地库代码推送到远程库, 多人协作时在push之前要先pull

第一次推送代码:git push -u origin master

git branch

列出所有分支(本地库)

git fetch

同步本地库和远程库的分支

git branch <分支名>

创建分支

git checkout <分支名>

切换分支

git checkout -b <分支名>

创建,切换分支

git merge <分支名>

合并分支代码到当前分支

git branch -d <分支名>

删除分支

git log --graph
show git branch praph
来自基友 爆炸峰

git常用指令(sourceTree挺香的)

标签:creat   path   git log   tty   fetch   日志   git仓库   rect   make   

原文地址:https://www.cnblogs.com/caoxueyang/p/13070298.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!