git 基本应用

1. git 安装
 
2.git 与服务器的验证
 
  1.生成ssh
    ssh-keygen -t rsa -C "1107247128@qq.com"
  2.查看生成的pub文件,并把秘钥添加到Git上
  3.测试连接ssh
    ssh -T git@git git@git.lagou.com
  3.设置本机在git中的身份
    git config --global user.name "zhidanwang19910111"
    git config --global user.email "1107247128@qq.com"
  4.创建一个库用来管理代码
    1.git init
    2.git remote add origin "远程库的ssh"
    3.将文件拷贝库
    4.git add .
    5.git commit -m ""
    6.git push -u origin master
    7.git remote -v 查看远程仓库
    8.git remote rm origin 删除远程仓库
  
  5.创建一个分支
    git branch 查看当前有几个分支
    git branch -a 查看全部分支,远程分支会红色表示出来
    git checkout -b "分支名称"
    git checkout 切换分支
    git push origin "分支名称"
 
    git branch -m old_branch new_branch # Rename branch locally 分支重命名
    git push origin :old_branch # Delete the old branch
    git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
  6. 强制回滚
    git reset --hard e377f60e28c8b84158
    git push -f origin master
    git log -3

posted @ 2019-05-25 16:02  zhidanwang  阅读(106)  评论(0编辑  收藏  举报