git push https://xxxx.git master 本地分支推送到远程 git remote add lianshou https://xxx.git 别名短地址 git push lianshou master git add 修改的代码放入暂存区 git commit 提交到本地仓库 git push 推送到远程 ssh-keygen -t rsa -C xxx@xxx.com 本地生成ssh key id_rsa私钥 id_rsa.pub公钥 git网站中配置这个 ================================================================== …or create a new repository on the command line echo "# git" >> README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/zhoutingze/git.git git push -u origin master ================================================================== …or push an existing repository from the command line git remote add origin https://github.com/zhoutingze/git.git git push -u origin master ================================================================== [root@localhost git]# git init [root@localhost git]# git config --global user.name "adtuu" [root@localhost git]# git config --global user.email 413920919@qq.com [root@localhost git]# touch index.php [root@localhost git]# git add . [root@localhost git]# git status [root@localhost git]# git commit -m 'init' [root@localhost git]# git status #关联一个远程库 [root@localhost git]# git remote add origin https://github.com/zhoutingze/git.git #由于远程库是空的,我们第一次推送master分支时,加上了-u参数,Git不但会把本地的分支内容推送的远程新的分支,还会把本地的master分支和远程的分支关联起来,在以后的推送或者拉取时就可以简化命令。$ git push origin master [root@localhost git]# git push -u origin master [root@localhost git]# git log index.php [root@localhost git]# git log 4aca0bfe537acd8d2e0ad4965431ec78794a0e27 #日志单行显示 [root@localhost git]# git log --pretty=oneline index.php 切换版本 [root@localhost git]# git reset --hard HEAD ^ #前一个版本 [root@localhost git]# git reset --hard HEAD ^^ #前二个版本 [root@localhost git]# git reset --hard HEAD ^^^ #前三个版本 [root@localhost git]# git log --pretty=oneline [root@localhost git]# git reset --hard 2580d #查看版本记录并切换 [root@localhost git]# git reflog [root@localhost git]# git reset --hard 2580d #查看某个版本和上一个版本区别 [root@localhost git]# git show 2580d #比较两个版本号内容 [root@localhost git]# git diff 旧版本号 新版本号 #git reset 后不能push,可以加上-f参数强制push [root@localhost git]# git push -f #将wechat分支合并到master分支 git checkout master git merge wechat #将本地分支wechat提交到远程 [root@localhost git]# git push origin wechat #将远程所有分支拉到本地 git fetch #删除本地分支,重新拉取远程分支 [root@localhost git]# git branch -d wechat [root@localhost git]# git fetch origin wechat:wechat #git revert #删掉原来git源,配置ssh免密方式 git remote remove origin git remote -v git remote add origin git@github.com:zhoutingze/git.git ssh-keygen -t rsa -C xxx@xxx.com #本地生成ssh key并复制id_rsa.pub内容保存到github站点对应的库设置中
git常用命令
阅读51评论02018-10-28 15:46:41
访客评论