git命令的基本使用

来源:互联网 发布:微信小店数据推送 编辑:程序博客网 时间:2024/05/18 02:30
上传代码至github或从gibhub下载代码到本地:
1.在远程服务器创建代码仓库,拿到仓库地址 
2.在本地创建一个目录,在当前目录中,打开命令提示符
3.先初始化git :git init
4.设置全局账号和邮箱:git config --global user.name ""
git config --global user.email ""
5.设置远程仓库地址:git remote add origin https:xxxxxx.xxx.xxx
6.从服务器下载代码:git pull origin master
7.查看当前修改状态:git status
8.把新加的文件添加到缓存中:git add 目录/文件名
10.把缓存中的文件,提交到本地Git仓库:git commit -m "提交注释"
11.把本地Git仓库同步到远程Git仓库:git push -f/-u origin master,要求输入账号和密码

经常用到的:
git pull origin branch-name 更新操作
git push 提交到远程代码仓库
git status 查看当前修改状态
git log 查看提交Log
git reset --hard commit号 代码回滚到指定提交的commit号

分支:
git branch -avv 查看所有分支
git branch new-branch-name 创建新分支
git checkout branch-name 切换分支 当前目录也会切到对应的分支目录
git push -u origin branch-name 提交代码到指定分支上
git merge branch-name 把指定的分支合并到当前分支上
0 0
原创粉丝点击