git工作中常用命令备忘录,推荐一个很好用的工具SourceTree
http方式克隆远程git仓库代码
git clone http://xxxxxx
本地提交所有已修改文件
git add .
git commit -m '说明'
git push
update 远程分支
git fetch
查看所有分支信息
git branch -a
切换分支
git checkout 分支名
新建分支并推送到远程仓库
git checkout -b 分支名
git pull
git push -u origin 分支名
//从别的分支把已提交的同步过来(commit id)
git cherry-pick id(commitID)
git push
//回滚到某个提交的节点
git reset 节点ID
##修改分支名称
git branch -m old_local_branch_name new_local_branch_name
##删除本地分支
git branch -D XXX
##删除远程分支
git push origin --delete XXX
##强制覆盖远程分支(慎用)
git push -f origin 分支名
##储藏本地修改代码《这样可以不提交本地修改的情况下切换的别的分支修改》
git stash //将已修改的代码隐藏
git stash list //查看隐藏的代码
git stash apply //恢复代码
git stash drop //删除储藏代码