远程仓库空仓库状态
git init
git remote add origin '远程仓库链接'
git pull origin master 下拉代码
git add .
git commit -m ""
git push -u origin master 首次提交
git push origin master 非首次提交
如果需要输入账号、密码,输入管理员账号密码(Gitee、Github)
远程已经建立了仓库, 且本地也已经建立了仓库
git init
git remote add origin "http://your remote repo address"
git add .
git commit -m"1"
git branch 判断分支
git config --global user.name "yourname"
git config --global user.email "youremail@"
git pull origin master 多人协作,需要吧远程master代码pull下来
git branch --set-upstream-to=origin/master master 分支远程<->本地
git pull origin master --allow-unrelated-histories 强制合并
git push
git initgit add .git commit -m ""git commit --amend::wq #类似linux的vi文本操作git config --global http.proxy http://192.168.80.202:808git config --global http.proxy https://192.168.80.202:808git config --global --unset http.proxygit config --global --unset https.proxygit config --global --get http.proxygit config --global --get https.proxygit config user.namegit config user.emailgit config --global user.name "your name”git config --global user.email "you@example.com"git remote add origin http://...git loggit log pretty=oneline 一行显示git refloggit reset --hard ...git rebase -i [startpoint] [endpoint] 弹出对话框,类似linux vi操控文件
pick:保留该commit(缩写:p)reword:保留该commit,但我需要修改该commit的注释(缩写:r)edit:保留该commit, 但我要停下来修改该提交(不仅仅修改注释)(缩写:e)squash:将该commit和前一个commit合并(缩写:s)fixup:将该commit和前一个commit合并,但我不要保留该提交的注释信息(缩写:f)exec:执行shell命令(缩写:x)drop:我要丢弃该commit(缩写:d)git pull --allow-unrelated-histories 参数是因为两个仓库毫无关联,需要加git pullgit pushgit remote -vi 可以查看你当前项目的远程git地址git fetch origin master:temp #[origin]不定,通过git remote -v查看远程仓库是什么git status 查看代码改动、所在分支、代码冲突等git merge [branch] 合并分支到mastergit checkout -b devgit branch --set-upstream-to=origin/remote_branch your_branchgit branch +分支名git switch +分支名git branch -d +分支名git diff [branch]git branch -agit push origin dev:dev 将dev分支提交到远程仓库git pull origin masterssh-keygen -t rsa -C "xxxxx@xxxxx.com"
ssh-keygen -t rsa -C 'xxxxx@company.com' -f gitee_id_rsa
cat ~/.ssh/id_rsa.pub
生成的位置:C:/Users/Administrator/.ssh
公钥添加完成后:
ssh -T git@gitee.com
The authenticity of host 'gitee.com (212.64.62.183)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
Hi liuwanqiang (DeployKey)! You've successfully authenticated, but GITEE.COM does not provide shell access.
Note: Perhaps the current use is DeployKey.
Note: DeployKey only supports pull/fetch operations
Hi XXX! You've successfully authenticated,
but Gitee.com does not provide shell access.
ssh -T git@gitee.com命令运行错误的解决方案cd ~/.ssh/mkdir ../.sshgit config --global user.name "Damogu"git config --global user.email "919740574@qq.com"ssh-keygen -t rsa -C "919740574@qq.com"
C:/Users/Han Dong/.ssh 目录
ssh -T git@github.com正常情况
出现如下信息:
Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.
Hi AssistantLiu! You've successfully authenticated, but GitHub does not provide shell access.
验证时可能让你输入YES,当出现以上信息时,说明配置成功,可以连接上GitHub;
异常情况
ssh: Could not resolve hostname github.com: \262\273\326\252\265\300\325\342\321\371\265\304\326\367\273\372\241\243
出现该问题原因是,因为电脑使用的是代理,公司内网,无法尚未,通过代理另一台电脑实现联网。