侧边栏壁纸
  • 累计撰写 208 篇文章
  • 累计创建 16 个标签
  • 累计收到 5 条评论

目 录CONTENT

文章目录

git 的简单命令

Wake
2022-08-08 / 0 评论 / 0 点赞 / 572 阅读 / 398 字

git新建分支并提交本地代码到远程分支

step1,在本地新建分支

git branch newbranch

step2:把本地分支push到远程

git push origin newbranch

step3:切换到该分支

git checkout newbranch

step4:查看本地修改

git status

step5:添加本地修改

git add .

step6:commit修改

git commit -m ‘XXXX’

step7:push代码

git push

1.建立GIt可管理的仓库

cd到本地项目根目录下,执行 git init 命令:

git init

2.将项目的所有文件添加到仓库中(注意add后面有一个“ . ”)

git add .

3.将上一步add的文件commit到仓库

git commit -m “提交的说明注释”

4.到GitHub官网新建一个仓库(Create repository),复制仓库地址

5.将本地仓库关联到GitHub新建的仓库上

git remote add origin https://github.com/Love-LG/Javaweb-firstcup-war

6.使用pull命令

git pull origin master

7.将本地仓库的文件上传到GitHub远程仓库

git push -u origin master

如果github上有新的文件,要先下载下来,再push:

git pull --rebase origion master

8、切换用户: git clone -b branch_name http://xxx (-b指分支)

cd branch_name
 再执行push操作

方式一:修改远程仓库地址 更换远程仓库地址,URL为新地址。 git remote set-url origin URL

方式二:先删除远程仓库地址,然后再添加 删除现有远程仓库 git remote rm origin

添加新远程仓库 git remote add origin url

查看远程仓库的地址 git remote -v

0

评论区