1、安装git和vscode
2、配置git(git 安装目录中)
1 git config --global user.name "xxx" 2 git config --global user.email "xxx@163.com"
3、vscode选择文件夹作为工作目录
4、vscode中进入命令面板搜索git,选择git初始化命令
5、在文件夹中选择git bash here
SSH模式
1 git remote add orgin git@github.com:xxx/aaa.git
HTTP模式
1 git remote add orgin https://github.com/xxx/aaa.git
注意 是orgin 还是 origin
xxx是你的github用户名, aaa.git 是你在github上的仓库名
ssh和http互换的时候
1 # 先看一下远端地址是否自己想要的 2 git remote -v 3 # 不是就移除 4 git remote remove origin
6、输入
1 git pull orgin master
将远程仓库拉到本地
1、个人在github上面创建了仓库,通过本地的git拉取远程仓库到本地报错信息如下:
http://www.mamicode.com/info-detail-2523100.html
git pull push出现There is no tracking information for the current branch错误
解决在通过git客户端 git pull的时候出现Threre is no tracking information for the current branch . Please specify which branch you want to merge with。
就是需要指定本地projet分支,跟远程仓库项目分支之间的关系,比如,我们需要本地master对应远程的master
1 git branch --set-upstream-to=origin/master master
再执行
1 git push --set-upstream orgin master
git 使用过程中问题解决
1
解决“fatal: 'origin' does not appear to be a git repository...”
当使用Git进行代码push提交时,出现报错信息“fatal: 'origin' does not appear to be a git repository...”,
$ git push -u origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
是因为远程不存在origin这个仓库名称,可以使用如下操作方法,查看远程仓库名称以及路径相关信息,可以删除错误的远程仓库名称,重新添加新的远程仓库;
git remote -v: 查看远程仓库详细信息,可以看到仓库名称
git remote remove orign: 删除orign仓库(如果把origin拼写成orign,删除错误名称仓库)!!!重点注意 极可能错误
git remote add origin 仓库地址: 重新添加远程仓库地址
gti push -u origin master: 提交到远程仓库的master主干
2.
解决"requested upstream branch 'origin/master' does not exist"
问题:
1、本地初始化了git仓库,放了一些文件进去并进行了add操作和commit提交操作;
2、github创建了git仓库并建立了README,.gitignore等文件;
3、本地仓库添加了github上的git仓库作为远程仓库,起名origin;
git remote add origin 远程仓库地址
4,本地仓库也远程仓库关联
git branch --set-upstream-to=origin/master master
这个时候就出现了
解决问题:
如果直接pull,就会出现
refusing to merge unrelated histories
的错误,正确姿势:
git pull origin master --allow-unrelated-histories
然后本地远程仓库关联
git branch --set-upstream-to=origin/master master
最后就可以push了;
总结一下:本地仓库有文件,远程仓库也有文件,正确姿势:
1,git remote add origin 远程仓库地址
2,git pull origin master --allow-unrelated-histories
3,git branch --set-upstream-to=origin/master master
4,git push
Git提交时出现Merge branch 'master' of ...之解决方法
解决方法
使用git pull --rebase命令,如果没有冲突,则会直接合并,如果存在冲突,手动解决冲突即可,不会再产生那条多余的信息。如果你不想每次都rebase,可以在git bash里执行
git config --global pull.rebase true
1
这个配置就是告诉git在每次pull前先进行rebase操作。
Git出现There is no tracking information for the current branch提示的解决办法
在执行git pull
的时候,提示当前branch没有跟踪信息:
1
|
There
is
no tracking information
for
the current branch
|
对于这种情况有两种解决办法,就比如说要操作master吧,一种是直接指定远程master:
1
|
git pull origin master
|
另外一种方法就是先指定本地master到远程的master,然后再去pull:
1
2
|
git branch
-
-
set
-
upstream
-
to
=
origin
/
master master
git pull
|