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倉庫地址: git@gitee.com: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  git@gitee.com: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 ' git@gitee.com: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 ' git@gitee.com: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
相關文章
相關標籤/搜索