git常用命令

GIT常规配置
$ git config -global user.name <name> #设置提交者名字
$ git config -global user.email <email> #设置提交者邮箱
$ git config -global core.editor <editor> #设置默认文本编辑器
$ git config -global merge.tool <tool> #设置解决合并冲突时差异分析工具
$ git config -list #检查已有的配置信息
使用git提交比较大的文件的时候可能会出现这个错误
error: RPC failed; result=22, HTTP code = 411
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date
这样的话首先改一下git的传输字节限制
git config http.postBuffer  524288000
git config --global http.postBuffer  524288000
$ git init  #初始化
$ git add . #添加当前目录所有内容
$ git commit -m "first commit."  #提交到本地库,并添加备注

远程操作

$ git remote -v #查看远程版本库信息
$ git remote show <remote> #查看指定远程版本库信息
$ git remote add <remote> <url> #添加远程版本库
$ git fetch <remote> #从远程库获取代码
$ git pull <remote> <branch> #下载代码及快速合并
$ git push <remote> <branch> #上传代码及快速合并
$ git push <remote> : <branch>/<tagname> #删除远程分支或标签
$ git push -tags #上传所有标签

详细说明

克隆项目:

git clone <URL>

克隆分支:

git clone -b branchName <URL>

克隆tag:

1、克隆整个项目(git clone <URL>2git checkout -b branchName tagName(tag是独立的项目,如果要编辑就要将其变为普通的分支)

添加并提交文件或文件夹

git add . | file
git commit -m "description"
 
git commit 之后发现有些文件不需要commit则用
git rm --cached 文件名 (删除本地仓库缓存文件,并不影响工作目录)

非git项目想加入git管理如下操作

git init  
git add .
git commit -m "first commit"
git remote add origin <URL>
git push origin -u master

删除已提交的文件或文件夹(删除本地文件然后提交,远程repository也会删除)

git rm -rf file | "folder"
git commit -m 'descriptiom'
git push -u origin master

检查已有的配置信息

git config --list | git config -l

设置提交者名字

git config --global user.name "userName"

设置提交者邮箱

git config --global user.email "userEmailAdress"

如果remote已经存在,想要修改remote url

git remote -v 查看remote
git remote origin 删除remote
git remote set-url origin <URL>

从远程git服务器上更新资源

git pull

比较两个版本文件的差异(并且将差异生成文件)

git diff folder/file folder/file > diff.txt

分支

创建一个叫做"lee"的分支,并切换过去

git checkout -b lee

切换回主分支

git checkout master

把新建的分支删除

git branch -d lee

push分支到远端仓库前,该分支不被人所见到

git push origin <branch>

改变分支名称

git branch -m old_name new_name

删除一个远程分支

git push origin --delete <branchName>

删除本地分支

git branch -D branchName

合并分支

有master分支创建develop分支
git checkout -b develop master
编辑develop后要合并分支
 
1、切换到master分支
git checkout master
 
2、合并develop分支到master
git merge --no-ff develop

tag

创建tag

git tag [tagName]
git tag -a [tagName] -m 'my version 1.4'

推送到服务器

1、推送所有tag 
  git push --tags
2、单个推送tag
  git push origin tagName

删除tag

git push origin --delete tag [tagName]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python Git常用命令大全: Git是现代化的版本控制系统,常被用于软件开发,协作和管理。它允许在开发过程中创建和管理不同的版本,跟踪文件的更改,以及支持团队合作。Python则是一种广泛应用于开发Web应用程序以及数据科学和人工智能领域的高级编程语言。在使用Git时,Python的代码可以与Git进行集成。这里是Python Git常用命令的大全: 1. git init:初始化一个新的 Git 仓库。 2. git clone:从现有的 Git 仓库克隆项目,可以是本地仓库或远端仓库。 3. git add:将文件添加到 Git 仓库中。git add . 可以添加所有更改。 4. git commit:将所有已添加的文件提交到本地 Git 仓库中。 5. git status:查看当前工作目录中 Git 仓库的状态。 6. git log:查看提交记录。 7. git push:将本地 Git 仓库的更改推送到远端仓库。 8. git pull:将远端 Git 仓库的更改拉到本地仓库。 9. git branch:创建新的分支。 10. git checkout:切换分支。 11. git merge:将一个分支的更改合并到另一个分支。 12. git revert:撤销一个提交。 13. git rebase:将一个分支的修改合并到当前分支。 14. git config:配置 Git。 15. git remote:管理远端仓库。 这是Python Git常用命令的大部分命令,但这并不是全部。在使用Git和Python时,这些命令应该是最为重要的。无论是在个人项目中还是团队合作中,这些命令会让你更加高效地使用Git,并保护你的代码免遭不可挽回地灾难。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值