git
设置git用户名/邮箱
git config --global user.name [username]
git config --global user.email [email]
查看已设配置
git config --list
但是这个仅仅是设置用户名密码,如果你的Git 源每次操作需要你输入用户名/密码验证,你依然需要每次设置,那么该如何办呢?
git保存用户名密码
这里主要是配置一个config项 有两个方法,基本上原理都是一样,都是修改.git/config文件
- 使用如下命令,修改config文件即可保存
echo -e "[credential]\n helper = store" >> .git/config
- 直接修改.git/config文件 vim .git/config
##修改成如下
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://github.com/Miss-you/kernel-netfilter-sample-code.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
##主要是后面这两行,如果不想保存,则删除即可
[credential]
helper = store
##保存
git init
#添加远程仓库
git remote add origin git@github.com:wing-ho/learngit.git
#push之前需要pull下来
git pull #已经把远程仓库的内容下载下来
git pull origin master #就不需要在重新下载了
#内容不一致,需要忽略历史
git merge origin/master --allow-unrelated-histories
修改远程仓库
项目一开始克隆了别人的项目,做了一些改动之后,觉得有必要pull request给项目作者,于是就fork一份到自己的仓库中,需要修改远程仓库地址到自己仓库,才能提交pull request。
git remote set-url origin https://github.com/wing-ho/tcrevenge.git
git push
同步更新github上fork的repo
方法一
1.打开你的github fork repo; 2.点击Pull request; 3.点击new pull request.默认情况下,github会比较original/your fork,这时应该不会有任何输出,因为你并没有做过任何变更; 4.点击switching the base.这时github将反过来比较yourfork/original,这时你将看到original相对你fork时的所有commit; 5.点击create a pull request,这时将会反过来向你的repo提交一个pull request; 6.这时你作为你自己fork的repo的owner,提交comment,点击confirm the merge,就合并所有的改动!
方法二:
git remote add upstream <pathtooriginalrepo>
git fetch upstream
git merge upstream/master master
git push origin master