git 常用操作

座右铭:怎么简单怎么来,以实现功能为主。

欢迎大家关注公众号与我交流

git branch -a # 查看所有分支

git branch test # 创建test分支

git checkout test # 切换到test分支

git checkout -b new-branch # 复制当前分支到新分支

git branch -D test # 删除test分支

git push origin --delete test # 删除远程分支 test

# 本地变更并同步到远程仓库:
    git add . # 添加

    git commit -m "第一次提交代码" # 添加commit注释

    git push # 提交到远程仓库

    git push --set-upstream origin test # 首次创建分支并没有同步到远程仓库时 需要此步操作

# 合并分支
    git branch test # 创建test分支

    git checkout test # 切换到test分支

    touch readme.txt # 在test分支添加一个readme.txt文件

    git add readme.txt # 添加add修改

    git commit -m “增加readme.txt” # 提交commit本地文件

    git checkout master # 切换到master分支

    git merge test # 把test分支合并到master分支

    git push origin master # 提交master分支到服务器


# 删除文件
    git rm 文件

    git commit -m 'xxxx'

    git push

# 重命名文件

    git mv a.go b.go

    git commit -m 'rename file'

    git push

你可能感兴趣的:(git)