git在idea中的使用,如何构远程git方仓库

 
配置用户名:$ git config --glob user.name "forever"
配置邮箱:$ git config --glob user.email "******* @163.com"
不管换行:$ git config --glob core.autocrlf false
 
编码:$ git config --glob gui.encoding  utf-8
避免git status乱码:$ git config --glob core.quotepath off
 
windows:
$ git config --glob core.ignorecase  false
 
$ ssh-keygen -t rsa -C "**** @163.com"
$ eval `ssh-agent`
$ ssh-add ~/.ssh/id_rsa
 
$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDL9BRs1EJbHaOi32W042X/hVY/DAJ2amBHvlm8zkYRcl7CS7f6Cwv+f/42Zw9oF/kjq1Rm9Mzjua8EMRVU/L7W1jeO158cs7shtCx97vcPu1q50zMCaj57J6XVZZCWvLWb484YUkY5PhgXLscc1Br5CfdDTAvNjfKQcKGo3cOSLPDqXoIb0MY1uvfyEluFQYZ/f+noY21Izug3cfn/zYGAM0FX5JHqkN6sitxMRHLVLsvbFehWDxnF*AubzxGSpP9sBX3KwwV1CQibt4Ej4XxJXCq5zNSWKaNj88LcSfAZ+2culfya7HFXeKcBItrbICJBT3BHa8z/TKanIQbJFbiV ***** @163.com
 
登陆  https://gitee.com/  去
设置中添加
公钥
 
完成
然后添加项目
 
添加完成如下图:
添加记住远程git仓库地址: [email protected]:forever2015_LLH/test_learning.git
 
 
 
本地操作,idea 
1.添加忽略配置文件
 
配置文件内容
*.class
#package file
*.war
*.ear
 
*.orig
 
target/
 
#eclipse ignore
.settings/
.progect
.classpath
 
#idea
.idea/
/idea/
*.ipr
*.iml
*.iws
 
#tem file
*.log
*.cache
*.diifgit
*.patch
*.tmp
 
 
#system ignore
.DS_Store
Thumbs.db
 
 
 
首先执行  git init ->在执行git status 查看要上传的文件 -> 添加 git add . ->在查看看到文件变化->在执行git commit(-am  '注释') 提交到本地仓库->提交到远程仓库地址 git remote add origin  [email protected]:forever2015_LLH_liuluheng2015/test1.git
 
查看当前分支:git branch
推送到远程git仓库: git push -u origin master
 
会出先错误:
E:\Java\2015WorkSpace>git push -u origin master
! [rejected]        master -> master (fetch first)
error: failed to push some refs to ' [email protected]:forever2015_LLH/test_learning.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
 
拉取:
E:\Java\2015WorkSpace>git pull
warning: no common commits
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
* [new branch]      master     -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
 
    git pull <remote> <branch>
 
If you wish to set tracking information for this branch you can do so with:
 
    git branch --set-upstream-to=origin/<branch> master
 
落后于当前:再次失败
E:\Java\2015WorkSpace>git push -u origin master
! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to ' [email protected]:forever2015_LLH/test_learning.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
 
(由于第一次所以强制推送)
E:\Java\2015WorkSpace>git push -u -f origin master
Counting objects: 18, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (18/18), 5.35 KiB | 0 bytes/s, done.
Total 18 (delta 0), reused 0 (delta 0)
remote: Powered by Gitee.com
+ a8d8c85...cdda889 master -> master (forced update)
Branch master set up to track remote branch master from origin.
 
查看远程分:git branch -r  然后根据主干创建本地分支
 
 
把本地分支推送到主干
 
git  push origin head -u
 
 
 
 
 
 
 
 
 

猜你喜欢

转载自www.cnblogs.com/Llh-Forerer2015/p/9772194.html