工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.51099.com 注册 | 登陆
浏览模式: 标准 | 列表分类:github

gitignore 不起作用的解决办法

 git rm -r --cached .

git add .
git commit -m 'update .gitignore'

git用户密码

 

 
git
SSL Error: unable to get local issuer certificate
git config --global http.sslVerify false
 
git http\https\git免密设置记住用户名和密码的方法
设置记住密码(默认15分钟):
git config --global credential.helper cache
如果想自己设置时间,可以这样做:
git config credential.helper 'cache --timeout=3600'
这样就设置一个小时之后失效
长期存储密码:
git config --global credential.helper store
增加远程地址的时候带上密码也是可以的。(推荐)
http://yourname:password@git.oschina.net/name/project.git
补充:使用客户端也可以存储密码的。
如果你正在使用ssh而且想体验https带来的高速,那么你可以这样做: 切换到项目目录下 :
cd projectfile/
移除远程ssh方式的仓库地址
git remote rm origin
增加https远程仓库地址
git remote add origin http://yourname:password@git.oschina.net/name/project.git

git常见问题

 问题

报错:error: The requested URL returned error: 401 Unauthorized while accessing
git版本:1.7.1

解决方法一:指定用户
git clone https://github.com/org/project.git

换成
git clone https://username@github.com/org/project.git
或者
git clone https://username:password@github.com/org/project.git

在push或者pull出出现的话,则需要更改远程地址
git remote set-url origin https://username@github.com/org/project.git

解决方法二:去除验证
git config –global http.sslverify false

解决方法三:(推荐)
升级git 版本≥1.7.10

解决方法四:
添加ssh秘钥

 

--------------

刚创建的github版本库,在push代码时出错:

$ git push -u origin master To git@github.com:******/Demo.git  ! [rejected]        master -> master (non-fast-forward) error: failed to push some refs to 'git@github.com:******/Demo.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Merge the remote changes (e.g. 'git pull') hint: before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

网上搜索了下,是因为远程repository和我本地的repository冲突导致的,而我在创建版本库后,在github的版本库页面点击了创建README.md文件的按钮创建了说明文档,但是却没有pull到本地。这样就产生了版本冲突的问题。

有如下几种解决方法:

1.使用强制push的方法:

$ git push -u origin master -f 

这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。

2.push前先将远程repository修改pull下来

git pull origin master

$ git push -u origin master

3.若不想merge远程和本地修改,可以先创建新的分支:

git branch [name]

然后push

git push -u origin [name]

git使用说明

 git reset --hard HEAD^^

 
git checkout -b v3
 
git branch origin/master
 
 
.gitconfig 文件中添加
 
[credential]
    helper = store
 
git config credential.helper 'cache –timeout=3600'
git config –global credential.helper store
 
 
git remote -v
 
 
git init
 
git remote add origin https://gitee.com/wdlinux/lanmp.git
 
把本地库的内容推送到远程,使用 git push命令,实际上是把当前分支master推送到远程。
 
由于远程库是空的,我们第一次推送master分支时,加上了 –u参数,Git不但会把本地的master分支内容推送的远程新的master分支,还会把本地的master分支和远程的master分支关联起来,在以后的推送或者拉取时就可以简化命令。推送成功后,可以立刻在github页面中看到远程库的内容已经和本地一模一样了,上面的要输入github的用户名和密码如下所示:
 
 
git checkout 命令加上 –b参数表示创建并切换,相当于如下2条命令
git branch dev
git checkout dev
git branch查看分支,会列出所有的分支,当前分支前面会添加一个星号。
 
 
现在我们可以把dev分支上的内容合并到分支master上了,可以在master分支上,使用如下命令 git merge dev 如下所示:
 
 
总结创建与合并分支命令如下:
   查看分支:git branch
   创建分支:git branch name
   切换分支:git checkout name
创建+切换分支:git checkout –b name
合并某分支到当前分支:git merge name
删除分支:git branch –d name
 
 
3.分支管理策略。
      通常合并分支时,git一般使用”Fast forward”模式,在这种模式下,删除分支后,会丢掉分支信息,现在我们来使用带参数 –no-ff来禁用”Fast forward”模式。首先我们来做demo演示下:
 
创建一个dev分支。
修改readme.txt内容。
添加到暂存区。
切换回主分支(master)。
合并dev分支,使用命令 git merge –no-ff  -m “注释” dev
查看历史记录
 
 
Git基本常用命令如下:
   mkdir:         XX (创建一个空目录 XX指目录名)
   pwd:          显示当前目录的路径。
   git init          把当前的目录变成可以管理的git仓库,生成隐藏.git文件。
   git add XX       把xx文件添加到暂存区去。
   git commit –m “XX”  提交文件 –m 后面的是注释。
   git status        查看仓库状态
   git diff  XX      查看XX文件修改了那些内容
   git log          查看历史记录
   git reset  –hard HEAD^ 或者 git reset  –hard HEAD~ 回退到上一个版本
                        (如果想回退到100个版本,使用git reset –hard HEAD~100 )
   cat XX         查看XX文件内容
   git reflog       查看历史记录的版本号id
   git checkout — XX  把XX文件在工作区的修改全部撤销。
   git rm XX          删除XX文件
   git remote add origin https://github.com/tugenhua0707/testgit 关联一个远程库
   git push –u(第一次要用-u 以后不需要) origin master 把当前master分支推送到远程库
   git clone https://github.com/tugenhua0707/testgit  从远程库中克隆
   git checkout –b dev  创建dev分支 并切换到dev分支上
   git branch  查看当前所有的分支
   git checkout master 切换回master分支
   git merge dev    在当前的分支上合并dev分支
   git branch –d dev 删除dev分支
   git branch name  创建分支
   git stash 把当前的工作隐藏起来 等以后恢复现场后继续工作
   git stash list 查看所有被隐藏的文件列表
   git stash apply 恢复被隐藏的文件,但是内容不删除
   git stash drop 删除文件
   git stash pop 恢复文件的同时 也删除文件
   git remote 查看远程库的信息
   git remote –v 查看远程库的详细信息
   git push origin master  Git会把master分支推送到远程库对应的远程分支上
 
http://blog.jobbole.com/78960/

git代理设置

 问题:

E:\PDFium>git clone https://pdfium.googlesource.com/pdfium
Cloning into 'pdfium'...
fatal: unable to access 'https://pdfium.googlesource.com/pdfium/': Failed connect to pdfium.googlesource.com:443; No error

解决:

git config --global http.proxy http://proxy.com:1234

git config --global https.proxy http://proxy.com:1234
git config --global http.sslverify false

转自:http://ricksu.blog.163.com/blog/static/18906433820125294929508/

参考:http://infong.net/config-proxy-for-git/

我使用本机上的小软件翻墙,所以设置为

E:\PDFium>git config --global http.proxy http://127.0.0.1:8580
E:\PDFium>git config --global https.proxy https://127.0.0.1:8580
E:\PDFium>git config --global http.SSLVERIFY false

docker_practice