小白篇--git基本操作

DEBUG操作

[链接](https://www.jianshu.com/p/704dc6b0bb18)

git push 失败,修改以下#标记的地方,可能会成功

[core]  ##########################
	repositoryformatversion = 0
	filemode = True
	bare = True
	logallrefupdates = true
	symlinks = false
	ignorecase = true
[remote "origin"]
	url = git@gitee.com:CrazyStoneonRoad/olcn-an-optimized-low-coupling-network-for-small-objects-detection.git
	fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
	remote = origin
	merge = refs/heads/master
[gui]
	wmstate = normal
	geometry = 1144x734+732+306 730 218
[http]
	postBuffer = 524288000
[pack]  ##########################
	window = 0
	windowMemory = 1024m

1级操作

修改git配置:

git config --global http.postBuffer 524288000 #修改git软件的配置
git config --local http.postBuffer 524288000 #只修改当前git库的配置

查看所有分支

git branch 
git branch -a

查看所有远程分支

git remote 
git remote -v

提交修改

git add recently_added_files.txt
git commit -a -m "add recently_added_files.txt and commit some changes"
git push -u origin-gitee

查看 git 状态

git status

快捷 add 所有:

git add --all

2级操作

克隆仓库

#Git global setup
git config --global user.name "YuanlinZhang"
git config --global user.email "zhangyuanlin.ucas@gmail.com"

#Create a new repository
git clone https://gitlab.com/CrazyStoneonRoad/test.git
cd test
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

#Push an existing folder
cd existing_folder
git init
git remote add origin https://gitlab.com/CrazyStoneonRoad/test.git
git add .
git commit -m "Initial commit"
git push -u origin master

#Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/CrazyStoneonRoad/test.git
git push -u origin --all
git push -u origin --tags

 git库,从新的远程库,pull到 新的本地分支

git remote add github-branch git@github.com:CrazyStoneonRoad/TGRS-HRRSD-Dataset.git
git branch mstr-gthb
git checkout mstr-gthb

ssh -T git git@github.com
git fetch github-branch mstr-gthb
git push -u github-branch

期间可能出现 remote end hang up ,修改如下:

vi .git/config

------insert---------------
[http]
postBuffer = 524288000

或者直接:

git config --global http.postBuffer 524288000 #修改git软件的配置
git config --local http.postBuffer 524288000 #只修改当前git库的配置
  • 再次上传,得到如下结果:

Enumerating objects: 36, done.
Counting objects: 100% (36/36), done.
Delta compression using up to 32 threads
Compressing objects: 100% (32/32), done.
Writing objects: 100% (32/32), 1.51 MiB | 113.00 KiB/s, done.
Total 32 (delta 11), reused 0 (delta 0)
remote: Resolving deltas: 100% (11/11), completed with 3 local objects.
remote:
remote: Create a pull request for 'mstr-gthb' on GitHub by visiting:
remote:      https://github.com/CrazyStoneonRoad/TGRS-HRRSD-Dataset/pull/new/mstr-gthb
remote:
To github.com:CrazyStoneonRoad/TGRS-HRRSD-Dataset.git
 * [new branch]        mstr-gthb -> mstr-gthb
Branch 'mstr-gthb' set up to track remote branch 'mstr-gthb' from 'github-branch'.

  • 这样对一个本地库,会有两个本地分支,两个分支互不影响。
  • 如果在分支1下删除了东西,切换到分支2下会看到删掉的东西还在;
  • 类似的,分支1下修改了东西,切换到分支2下会看到东西还没修改;

git将一个分支的提交,合并到另一个分支

git checkout A
git log

> copy the last_commit_id (such as 325d41)

git checkout B
git cherry-pick $last_commit_id

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值