git 提交出現(xiàn)這個錯誤fatal: Unable to create 'project_path/.git/index.lock': File exists.

1.git 提交出現(xiàn)這個錯誤fatal: Unable to create ‘project_path/.git/index.lock’: File exists. exists

解決辦法

打開git Bash 進(jìn)入項目目錄 ?輸入rm -f ./.git/index.lock ? 再回到AS就可添加了

on Windows

del .git\index.lock


2.使用git 添加遠(yuǎn)程github倉庫的時候提示錯誤:fatal: remote origin already exists.


到解決辦法如下:

1、先刪除遠(yuǎn)程 Git 倉庫

$ git remote rm origin

2、再添加遠(yuǎn)程 Git 倉庫

$ git remote add origin git@github.com:FBing/java-code-generator

如果執(zhí)行 git remote rm origin 報錯的話,我們可以手動修改gitconfig文件的內(nèi)容

$ vi .git/config


把 [remote “origin”] 那一行刪掉就好了。

3. non-fast-forward

$ 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.

網(wǎng)上搜索了下,是因為遠(yuǎn)程repository和我本地的repository沖突導(dǎo)致的,而我在創(chuàng)建版本庫后,在github的版本庫頁面點擊了創(chuàng)建README.md文件的按鈕創(chuàng)建了說明文檔,但是卻沒有pull到本地。這樣就產(chǎn)生了版本沖突的問題。

有如下幾種解決方法:

1.使用強(qiáng)制push的方法:

$ git push -u origin master -f

這樣會使遠(yuǎn)程修改丟失,一般是不可取的,尤其是多人協(xié)作開發(fā)的時候。

2.push前先將遠(yuǎn)程repository修改pull下來

$git pull origin master

$ git push -u origin master

3.若不想merge遠(yuǎn)程和本地修改,可以先創(chuàng)建新的分支:

$git branch [name]

然后push

$git push -u origin [name]


報這個錯用git config --global http.sslVerify false然后重啟就好了


寫這個似乎沒用

4,git常用命令

1. git 配置:

git config--globaluser.name"xxx"--配置用戶名,上傳本地 repository 到服務(wù)器上的時候,在 Github 上會顯示這里配置的上傳者信息

git config--globaluser.email"xxx"--配置郵箱

git config--list? ? ? ? 查看配置列表

配置 sshkey : 上傳代碼時使用這個 sshkey 來確認(rèn)是否有上傳權(quán)限

1). 創(chuàng)建本地 ssh :

cd ~/.ssh

ssh-keygen -t rsa -C"Github 的注冊郵箱"2). 在 Github 中添加這個 sshkey :

復(fù)制? /home/bruceking90/.ssh/id_rsa.pub 文件中的內(nèi)容;

登錄 Github--> Account Setting? --> SSH-KEY --> Add SSH-KEY -->粘貼id_rsa.pub中的內(nèi)容;3). 驗證: ssh -T git@github.com

出現(xiàn) Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. 說明配置成功,可以連接上 Github

2. 建立倉庫 repository :

git init here--創(chuàng)建本地倉庫

git remote add origin git@github.com:用戶名/倉庫名.git--把本地倉庫和遠(yuǎn)程倉庫關(guān)聯(lián)起來, 如果不執(zhí)行這個命令的話,每次 push 的時候都需要指定遠(yuǎn)程服務(wù)器的地址

3. 從遠(yuǎn)程倉庫中下載新的改動:

git pull origin master4. 提交本地修改到遠(yuǎn)程倉庫中:

git add

git add-A? ? ? --將改動添加到本地倉庫中

git rm xxx--從本地倉庫中刪除指定文件

git rm-r xxx? --從本地倉庫中刪除指定文件夾

git commit-m"注釋"--把本機(jī)緩存中的內(nèi)容提交到本機(jī)的 HEAD 里面

git push origin master--把本地的 commit push 到遠(yuǎn)程倉庫中

(注釋:如果出現(xiàn)推送錯誤,可以強(qiáng)制性推送git push origin +master或者先git pull,然后再操作庫)

如果有permission deneied,嘗試:?? ssh -i ~/.ssh/id_rsa -vT git@github.com?? ssh-agent?? ssh-add ~/.ssh/id_rsa

Git 常用命令

git init--創(chuàng)建本地倉庫(repository),將會在文件夾下創(chuàng)建一個 .git 文件夾,.git 文件夾里存儲了所有的版本信息、標(biāo)記等內(nèi)容

git remote add origingit@github.com:用戶名/倉庫名.git--把本地倉庫和遠(yuǎn)程倉庫關(guān)聯(lián)起來。如果不執(zhí)行這個命令的話,每次 push 的時候都需要指定遠(yuǎn)程服務(wù)器的地址

git add--從本地倉庫增刪,結(jié)果將會保存到本機(jī)的緩存里面

git rm

git commit-m"注釋"--提交,把本機(jī)緩存中的內(nèi)容提交到本機(jī)的 HEAD 里面

git push origin master-- 把本地的 commit(提交) push 到遠(yuǎn)程服務(wù)器上, origin 也就是之前 git remote add origin 那個命令里面的 origin,origin 替代了服務(wù)器倉庫地址:git pushgit@github.com:用戶名/倉庫名.gitgit pull origin master--從遠(yuǎn)程服務(wù)器 pull 新的改動

git status--查看狀態(tài)

git add-A? ? ? ? ? ? ? --提交全部修改

git clone

使用 git clone 拷貝一個 Git 倉庫到本地,讓自己能夠查看該項目,或者進(jìn)行修改。

如果你需要與他人合作一個項目,或者想要復(fù)制一個項目,看看代碼,你就可以克隆那個項目。 執(zhí)行命令:

git clone [url]



yuleyouxi

yuleyouxi

那說明你有修改過的文件

git提交報錯:Counting objects: 198, done.

Delta?compression?using?up?to?4?threads.

Compressing?objects:?100%?(109/109),?done.

Writing?objects:?100%?(137/137),?405.67?KiB,?done.

Total?137?(delta?74),?reused?0?(delta?0)

remote:?W?refs/heads/intg/dev?scm/p400_system?hongyang.song?DENIED?by?fallthru

remote:?error:?hook?declined?to?update?refs/heads/intg/dev

To?git@10.114.110.37:scm/p400_system.git

!?[remote?rejected]?intg/dev?->?intg/dev?(hook?declined)

!?[rejected]????????master?->?master?(non-fast-forward)

error:?failed?to?push?some?refs?to?'git@10.114.110.37:scm/p400_system.git'

To?prevent?you?from?losing?history,?non-fast-forward?updates?were?rejected

Merge?the?remote?changes?(e.g.?'git?pull')?before?pushing?again.??See?the

'Note?about?fast-forwards'?section?of?'git?push?--help'?for?details.

git?stash

git?pull?--rebase?(每次push之前最好這樣做一次)

git?push?....

之后用git?stash?pop?stash@{0}回復(fù)你之前修改的文件就

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1. 安裝 Github 查看是否安裝git: $ git config --global user.name "...
    Albert_Sun閱讀 13,835評論 9 163
  • Lesson 3: Using GitHub to Collaborate 3.1 Creating a GitH...
    赤樂君閱讀 6,339評論 3 11
  • 親們,我不是真正做微商,真正做微商賣東西的,那價錢都是翻了幾倍的。我賣的這些東西,說實在的有時候還要倒貼郵費,但我...
    野丫頭女孩閱讀 395評論 0 0
  • 酒千杯 愁萬縷 多重心味無語 欲話別 淚先流 夜闌酒醒處 寒風(fēng)起 霜滿天 別情猶在殘酒 一手手 一聲聲 斷腸各天涯...
    ecf33a82606f閱讀 334評論 0 1
  • 上報紀(jì)檢材料 編寫材料上報至區(qū)紀(jì)委
    66428ff08f4f閱讀 160評論 0 0

友情鏈接更多精彩內(nèi)容