赞
踩
Git是目前世界上最先进的分布式版本控制系统(没有之一),什么是版本控制?大白话就是可以控制每个人每一次提交,保证代码互不干扰,可进行历史记录查询、回退版本、分支合并,极大的提高了协同开发的效率
git clone
后的状态,即将代码缓存cache到本地git add
之后的状态,即将代码添加至暂存区git commit
之后的状态,即将代码提交到本地仓库git push
之后的状态,即将代码推送到在远端仓库git branch
git branch -v
git branch -vv
git branch -r
git branch -a
git config --global --list
git branch -vv
git status
git diff test.py
git remote show origin
git stash list
git stash show stash@{0}
git log
git status -sb
git reflog --date=local | grep test
git rm test.txt
git rm --cache test.txt
git branch -d test
git status -D test
git push --delete origin test
git stash drop stash@{0}
git stash clear
git clean -f
.idea
添加至.gitignore
文件提交至远程仓git rm --cached -r .idea
git clone test
git pull
git push
git add test.txt
git add .
git branch test
git branch test
git push origin test:test # 第一个test是本地分支名,第二个是远端分支名
git stash save 0
git commit -m test
git branch -m oldName newName
git commit --amend
# 修改git的远程地址。假设远端映射到本地名为origin
git remote set-url origin http://x.xx.xxx.xxxx:yyyy/zzz.git
git restore test.py
git reset head test.py
git restore --staged
git reset --hard HEAD^
git reset --mixed HEAD^
等同于git reset HEAD^
git reset --soft HEAD^
git stash apply stash@{0}
git stash apply stash@{0} --index
git stash pop
git checkout -b test
git commit -am test
注:merge合并时,要变更的分支(即当前所处分支)内不应存在未commit的文件,否则会导致这些文件无法恢复到merge前的状态。解决方法是merge之前将其stash到缓存中,merge结束后pop再还原回来
git cherry-pick test001
git rebase -i test001
git merge dev
git branch --set-upstream-to=origin/ogn_test test
git reset --merge
,其实这是老版本的语法,最新的语法合并回退命令如下:git merge --abort
git checkout test
git checkout dev
git push --delete origin test
,须知,此时只是删除了远端分支,本地分支还存在,只是缺少了上游分支git remote show origin
,输入账号密码确认查看git remote prune origin
git checkout dev
git branch -m test newName
git push --delete origin test
git push origin newName
git branch --set-upstream-to origin/newName
git remote add gitee https://xxxx.com/yyyyyy/zzzz.git
git remote update gitee --prune
,若出现errorfailed to push some refs to
,可尝试在git地址上配置用户名&密码Ⅰ编辑git文件git config -eⅡ修改git地址为http://host:pwd@xx/yy/zz.git
git branch -vv
git checkout master
git merge main --allow-unrelated-histories
(–allow-unrelated-histories是解决两仓库不同历史记录冲突的)git add .
git commit -m "迁移代码至新仓库"
并上传git push
,若push失败,可强制git push -f gitee master
,执行强制需明确此风险git branch -b yourbranch
git push --set-upstream origin yourbranch
以上就是本文全部内容,希望可以给予你们以帮助!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。