您的位置:首页 > 其它

git操作命令整理

2016-06-24 10:32 344 查看
1、mkdir(创建目录)

2、pwd(用户显示当前目录)

3、git init(把该目录变成Git可以管理的仓库)

4、ls -ah(列出该目录下的所有文件)

5、git add <file-path>(把文件添加到仓库)

6、git reset <file-path>(取消添加的新文件)

7、git rm <file-path>(从git删除文件,不再repo里管理)

8、git diff(查看本地未确认的修改)

9、git diff --cached(查看本地已确认但未提交的修改)

10、git status(查看本地修改的文件状态)

11、git commit -m "short commit message"(本地提交,生成一个版本)

12、git log(查看提交记录)

13、git checkout --<file-path>(撤销一个文件的修改)

14、git checkout --(撤销当前目录的所有修改)

15、git branch <new branch>(创建分支,基于当前分支)

16、git branch <new-branch> <base-branch>(基于某个分支创建分支)

17、git checkout <branch>(切换分支)

18、git checkout -b <new-branch> [base-branch](创建新分支并立即切过去)\

19、git merge <other-branch>(合并一个分支到当前分支)

20、git branch -d <branch>(安全删除(已经合并过的)本地分支)

21、git branch --set-upstream develop origin/develop((已存在的)本地分支关联到服务器分支)

22、git pull(获取服务器(所有的)更新,并合并当前远程分支的更新)

23、git pull origin <branch>(获取某个远程分支的更新(到当前分支!!))\

24、git fetch [origin [<remote-branch-name>]](仅拉取服务器更新,但不合并或 rebase)

25、git push origin <branch>(向服务器提交更新(首先你的本地分支已经关联了远程分支))

26、git push origin --delete <remote-branch>(删除服务器远程分支)

27、git tag <tag-name> <branch-or-revision>(创建一个标签)
28、git push --tags(提交标签到服务器)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  git