GIT和Apache Subversion属于常见的代码版本控制的工具,本帖小记GIT常用指令已作参考。
https://windows.github.com
https://mac.github.com
http://git-scm.com
GIT常用的设置有HTTPS和SSH俩种。
###HTTPS
通过账号ID和密码访问
为了便于日常使用, 账号信息可配置为全局变量:
git config --global user.name "[user-name]"
git config --global user.email "[email address]"
git config --global color.ui auto
###SSH
通过预设的SSH keys来访问
git init [project-name]
git clone https://github.com/[user-name]/[project-name]
git remote -v # Check URL
git status # Check local statue
git diff
git diff --staged
git stash
git stash pop
git stash list
git stash drop
文件修改之后需要通过commit来提交修改:
git commit "[descriptive message]"
git push remote origin/[branch-name]
git add [file]
删除单文件
git rm [file]
从GIT删除单文件,但保留本地缓存
git rm --cached [file]
Reset single file
git reset [file]
Rename single file
git mv [file-original] [file-renamed]
查看本地Branch
git branch
查看远程Branch
git branch -r
建立新本地Branch
git branch [branch-name]
与远程Branch同步
git pull origin/[branch-name]
切换Branch
git fetch
git checkout [branch-name]
合并Branch到当前Branch (可能会导致冲突, 需要修改删除所有被 <<< 指出的冲突代码)
git merge origin/[branch-name]
提交Branch到远程
git push origin/[branch-name]
删除本地Branch
git branch -d [branch-name]
Rebase: reapply commits on top of another base tip
git rebase -i
git rebase master [branch-name] # rebase branch to top of master
git log
git log --follow [file]
git diff [first-branch]...[second-branch]
git show [commit]
撤销到指定commit:
git reset [commit]
强制撤销到指定commit
git reset --hard [commit]
撤回上个commit的修改
git reset HEAD~
git add [file-name] # Modify changes
git commit -c ORIG_HEAD
git reset –hard HEAD~N # merge to last N commit
git merge –squash HEAD@{1}
git commit "[descriptive message]"
git push -f origin [branch-name]
git reset –hard origin/[branch-name]
git clean -df
原文:https://www.cnblogs.com/robinali/p/15151620.html