Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git的使用 #13

Open
millzhang opened this issue Mar 1, 2018 · 0 comments
Open

git的使用 #13

millzhang opened this issue Mar 1, 2018 · 0 comments

Comments

@millzhang
Copy link
Owner

millzhang commented Mar 1, 2018

下载代码

git clone https://github.com/MillZhang/work-desk.git

添加文件

git commit -m '注释'

提交三步曲

git add
git pull
git commit -m ''
git push

git status

查询repo的状态.
git status -s: -s表示short, -s的输出标记会有两列,第一列是对staging区域而言,第二列是对working目录而言.

查看当前协议

git remote -v  

https切换回ssh

git remote set-url origin git@github.com:MillZhang/work-desk.git

不输入用户名密码提交指南

  1. https切换回ssh
  2. 生成ssh-key
  1. 打开git,git config --global user.name "xxx"
  2. ssh-keygen -t rsa -C "xxxx@qq.com"
  3. 打开https://github.com/settings/keys 添加ssh-key

错误

  1. Changes not staged for commit
git commit -am "" or git commit -m 'msg' -a
//-a 表示 all
  1. git commit 进入 vim 如何操作?

按i然后写入,写入后按esc键退出编辑状态,然后输入:wq,回车即可

2018-3-2[新增] 本地分支推送到远程仓库

  1. git init创建本地git仓库
  2. git add添加文件到暂存区
  3. git commit -m "init commit ",将暂存区的文件推送到git仓库
  4. 在服务端新建一个git代码库,如:git@github.com:MillZhang/python-demo.git
  5. 关联本地代码库与远程代码库:git remote add origin git@github.com:MillZhang/python-demo.git

执行完这个操作后,打开.git/config文件,多出一下的信息:

[remote "origin"]
	url = git@github.com:MillZhang/python-demo.git
	fetch = +refs/heads/*:refs/remotes/origin/*
  1. 先进行代码的合并,git pull --rebase origin master,注:pull=fetch+merge

执行完这个操作后,打开.git/config文件,多出一下的信息:

[branch "master"]
	remote = origin
	merge = refs/heads/master

  1. 上传代码:git push -u origin master

注: 如果省略了步骤6,远程仓库与本地代码不一致的话,则会出现如下的错误

error: failed to push some refs to 'git@github.com:MillZhang/python-demo.git'

https://www.cnblogs.com/code-changeworld/p/4779145.html

附录

  1. 常用命令
  2. git emoji
  3. 无权限提交
  4. ssh-key的生成
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant