日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

git学习心得

發布時間:2024/1/8 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 git学习心得 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

? ?git是一款十分有用的版本控制軟件,程序員必備。

http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013743256916071d599b3aed534aaab22a0db6c4e07fd0000


1.生成key?

ssh-keygen?-t?rsa? 將生成的位于.ssh下的pub文件cat后,復制到git的ssh key當中。


2.在.ssh目錄下2新建config,加入port XXXX (端口)


3.修改config權限 chmod 600


4.git pull origin master 該步驟要位于當前工作空間之下

當前工作空間:

F:\Program Files\Git\guoxungit\hearthdap-front



//取消更改 回滾到上次狀態

1.git reset --hard

2.git reset --hard head^^ //回滾到上上次 ……head~1//回滾到上一次版本


一.提交代碼操作流程:

1.查看當前本地分支 git branch


2.查看網絡分支 git branch -a


3.添加本地分支 git branch guoxun


4.切換到本地分支 git checkout guoxun


5.git status 查看當前文件狀態


6.文件的三種狀態 只有暫存區域的文件(即:文件狀態為“Changes to be committed”)才會被提交
http://phplaber.iteye.com/blog/1699926
除了之前的“Changes to be committed”狀態,現在又多了一條“Changes not staged for commit”狀態,表明文件已經修改,但是還沒有放入暫存區域,也就是沒生成快照。如果現在進行commit操作,只是將修改之前的文件快照提交到了git目錄,一定記住:只有暫存區域的文件(即:文件狀態為“Changes to be committed”)才會被提交。正如提示,通過“git add README.txt”命令將已修改文件更新到暫存區域中,如果想撤銷修改,可以使用“git checkout -- README.txt”命令


7.git add application/ 將以application開頭的文件設為Changes to be committed狀態


8.git reset HEAD .idea 將以.idea開頭的文件從change to be committed狀態回退到前一個狀態


9.git log 查看近期修改日志


10.git commit -m "add index of help" 提交


11.git push origin guoxun 把修改提交到分支上


操作記錄:



admin@guoxun MINGW64 /guoxungit (master)
$ git branch
* master


admin@guoxun MINGW64 /guoxungit (master)
$ git checkout


admin@guoxun MINGW64 /guoxungit (master)
$ git branch -a
* master
? remotes/origin/master


admin@guoxun MINGW64 /guoxungit (master)
$ git branch guoxun


admin@guoxun MINGW64 /guoxungit (master)
$ git branch
? guoxun
* master


admin@guoxun MINGW64 /guoxungit (master)
$ git checkout test
error: pathspec 'test' did not match any file(s) known to git.


admin@guoxun MINGW64 /guoxungit (master)
$ git checkout guoxun
Switched to branch 'guoxun'


admin@guoxun MINGW64 /guoxungit (guoxun)
$ git push origin guoxun
Total 0 (delta 0), reused 0 (delta 0)
To git@git.qyidea.com:hui.chen/hearthdap-front.git
?* [new branch] ? ? ?guoxun -> guoxun


admin@guoxun MINGW64 /guoxungit (guoxun)
$ ls
application/ ?hearthdap-front/ ?spacerscoringcrispr-code/
assets/ ? ? ? index.php ? ? ? ? system/
download/ ? ? license.txt ? ? ? user_guide/


admin@guoxun MINGW64 /guoxungit (guoxun)
$ cd hearth-front
bash: cd: hearth-front: No such file or directory


admin@guoxun MINGW64 /guoxungit (guoxun)
$ cd hearthdap-front/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (master)
$ ls
application/ ?CodeIgniter-3.0.2.zip ?index.html ?license.txt ?user_guide/
assets/ ? ? ? download/ ? ? ? ? ? ? ?index.php ? system/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (master)
$ git branch guoxun


admin@guoxun MINGW64 /guoxungit/hearthdap-front (master)
$ git checkout guoxun
A ? ? ? .idea/vcs.xml
M ? ? ? application/libraries/Cipredis.php
Switched to branch 'guoxun'


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git push origin guoxun
Everything up-to-date


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ ^C


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ ^C


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ ^C


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ ^C


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git commit
Aborting commit due to empty commit message.


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git commit -m "helpindex"
error: pathspec 'helpindex' did not match any file(s) known to git.


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git status
On branch guoxun
Changes to be committed:
? (use "git reset HEAD <file>..." to unstage)


? ? ? ? new file: ? .idea/vcs.xml


Changes not staged for commit:
? (use "git add <file>..." to update what will be committed)
? (use "git checkout -- <file>..." to discard changes in working directory)


? ? ? ? modified: ? application/libraries/Cipredis.php


Untracked files:
? (use "git add <file>..." to include in what will be committed)


? ? ? ? .idea/.name
? ? ? ? .idea/copyright/
? ? ? ? .idea/deployment.xml
? ? ? ? .idea/encodings.xml
? ? ? ? .idea/hearthdap-front.iml
? ? ? ? .idea/misc.xml
? ? ? ? .idea/modules.xml
? ? ? ? .idea/workspace.xml
? ? ? ? .project
? ? ? ? .settings/
? ? ? ? CodeIgniter-3.0.2.zip
? ? ? ? application/controllers/helpIndex.php
? ? ? ? application/views/helpIndex.tpl
? ? ? ? assets/images/helpView.jpg
? ? ? ? index.html




admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ ^C


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ ^C


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git add application/
controllers/ libraries/ ? views/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git add application/
controllers/ libraries/ ? views/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git add application/
controllers/ libraries/ ? views/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git add application/
controllers/ libraries/ ? views/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git add application/
controllers/ libraries/ ? views/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git add application/
controllers/ libraries/ ? views/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git add application/
controllers/ libraries/ ? views/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git add assets/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git satus
git: 'satus' is not a git command. See 'git --help'.


Did you mean this?
? ? ? ? status


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git status
On branch guoxun
Changes to be committed:
? (use "git reset HEAD <file>..." to unstage)


? ? ? ? new file: ? .idea/vcs.xml
? ? ? ? new file: ? assets/images/helpView.jpg


Changes not staged for commit:
? (use "git add <file>..." to update what will be committed)
? (use "git checkout -- <file>..." to discard changes in working directory)


? ? ? ? modified: ? application/libraries/Cipredis.php


Untracked files:
? (use "git add <file>..." to include in what will be committed)


? ? ? ? .idea/.name
? ? ? ? .idea/copyright/
? ? ? ? .idea/deployment.xml
? ? ? ? .idea/encodings.xml
? ? ? ? .idea/hearthdap-front.iml
? ? ? ? .idea/misc.xml
? ? ? ? .idea/modules.xml
? ? ? ? .idea/workspace.xml
? ? ? ? .project
? ? ? ? .settings/
? ? ? ? CodeIgniter-3.0.2.zip
? ? ? ? application/controllers/helpIndex.php
? ? ? ? application/views/helpIndex.tpl
? ? ? ? index.html




admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git add application/


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git status
On branch guoxun
Changes to be committed:
? (use "git reset HEAD <file>..." to unstage)


? ? ? ? new file: ? .idea/vcs.xml
? ? ? ? new file: ? application/controllers/helpIndex.php
? ? ? ? modified: ? application/libraries/Cipredis.php
? ? ? ? new file: ? application/views/helpIndex.tpl
? ? ? ? new file: ? assets/images/helpView.jpg


Untracked files:
? (use "git add <file>..." to include in what will be committed)


? ? ? ? .idea/.name
? ? ? ? .idea/copyright/
? ? ? ? .idea/deployment.xml
? ? ? ? .idea/encodings.xml
? ? ? ? .idea/hearthdap-front.iml
? ? ? ? .idea/misc.xml
? ? ? ? .idea/modules.xml
? ? ? ? .idea/workspace.xml
? ? ? ? .project
? ? ? ? .settings/
? ? ? ? CodeIgniter-3.0.2.zip
? ? ? ? index.html




admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git rm .idea
fatal: not removing '.idea' recursively without -r


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git rm .idea/
fatal: not removing '.idea/' recursively without -r


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git rm .idea/vcs.xml
error: the following file has changes staged in the index:
? ? .idea/vcs.xml
(use --cached to keep the file, or -f to force removal)


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git checkout
A ? ? ? .idea/vcs.xml
A ? ? ? application/controllers/helpIndex.php
M ? ? ? application/libraries/Cipredis.php
A ? ? ? application/views/helpIndex.tpl
A ? ? ? assets/images/helpView.jpg


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git status
On branch guoxun
Changes to be committed:
? (use "git reset HEAD <file>..." to unstage)


? ? ? ? new file: ? .idea/vcs.xml
? ? ? ? new file: ? application/controllers/helpIndex.php
? ? ? ? modified: ? application/libraries/Cipredis.php
? ? ? ? new file: ? application/views/helpIndex.tpl
? ? ? ? new file: ? assets/images/helpView.jpg


Untracked files:
? (use "git add <file>..." to include in what will be committed)


? ? ? ? .idea/.name
? ? ? ? .idea/copyright/
? ? ? ? .idea/deployment.xml
? ? ? ? .idea/encodings.xml
? ? ? ? .idea/hearthdap-front.iml
? ? ? ? .idea/misc.xml
? ? ? ? .idea/modules.xml
? ? ? ? .idea/workspace.xml
? ? ? ? .project
? ? ? ? .settings/
? ? ? ? CodeIgniter-3.0.2.zip
? ? ? ? index.html




admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git reset head .idea/vcs.xml


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git status
On branch guoxun
Changes to be committed:
? (use "git reset HEAD <file>..." to unstage)


? ? ? ? new file: ? application/controllers/helpIndex.php
? ? ? ? modified: ? application/libraries/Cipredis.php
? ? ? ? new file: ? application/views/helpIndex.tpl
? ? ? ? new file: ? assets/images/helpView.jpg


Untracked files:
? (use "git add <file>..." to include in what will be committed)


? ? ? ? .idea/
? ? ? ? .project
? ? ? ? .settings/
? ? ? ? CodeIgniter-3.0.2.zip
? ? ? ? index.html




admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git reset head application/libraries/Cipredis.php
Unstaged changes after reset:
M ? ? ? application/libraries/Cipredis.php


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git status
On branch guoxun
Changes to be committed:
? (use "git reset HEAD <file>..." to unstage)


? ? ? ? new file: ? application/controllers/helpIndex.php
? ? ? ? new file: ? application/views/helpIndex.tpl
? ? ? ? new file: ? assets/images/helpView.jpg


Changes not staged for commit:
? (use "git add <file>..." to update what will be committed)
? (use "git checkout -- <file>..." to discard changes in working directory)


? ? ? ? modified: ? application/libraries/Cipredis.php


Untracked files:
? (use "git add <file>..." to include in what will be committed)


? ? ? ? .idea/
? ? ? ? .project
? ? ? ? .settings/
? ? ? ? CodeIgniter-3.0.2.zip
? ? ? ? index.html




admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git checkout application/libraries/Cipredis.php


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git log
commit f258c36490d35ff956d47956bfb67bfc45eaf940
Merge: d1a272e 30ae67c
Author: Hui.Chen <hui.chen@qyidea.com>
Date: ? Thu Jan 14 16:32:26 2016 +0800


? ? Merge branch 'dev' of git.qyidea.com:hui.chen/hearthdap-front


commit d1a272e9d568c5f60c0e1f5eda76765d5d67c090
Author: Hui.Chen <hui.chen@qyidea.com>
Date: ? Thu Jan 14 16:31:22 2016 +0800


? ? remove authorized_keys


commit 30ae67c27ccb6e72552e8f08f51e69de0125bef0
Author: sjh <jiahe404@163.com>
Date: ? Tue Jan 12 16:21:11 2016 +0800


? ? Get match datas from db and fill in the table


commit a24f88c55d0e110b06a38c9314f8b9541aa6f360
Merge: 8718e47 d911fbc
Author: Hui.Chen <hui.chen@qyidea.com>
Date: ? Mon Dec 21 22:18:04 2015 +0800


? ? Merge branch 'feature-update' of git.qyidea.com:hui.chen/hearthdap-front


commit 8718e475ce892ddecedf5cadd810d36ca2473a22
Author: Hui.Chen <hui.chen@qyidea.com>
Date: ? Mon Dec 21 22:13:52 2015 +0800


? ? modify user info ajax interface to handle response


commit d911fbc1834f12d58420e8f061b9804e8750df42
Author: sunjiahe <jiahe404@163.com>
Date: ? Mon Dec 21 20:13:57 2015 +0800


? ? modify the function getDeckStatus


commit 35b40be45c2c2e97f30f1d838e4a5d74214c83d1
Author: sunjiahe <jiahe404@163.com>
Date: ? Mon Dec 21 16:22:47 2015 +0800


? ? modify potential bugs


commit 822bc656c705464de57e36bc0c21212331a43b15
Author: sunjiahe <jiahe404@163.com>
Date: ? Mon Dec 21 15:24:36 2015 +0800


? ? modify a description of a function


commit 48e2ddc5e3df2640bc8a004df78a3d2953df0a29
Author: sunjiahe <jiahe404@163.com>
Date: ? Mon Dec 21 14:58:46 2015 +0800


? ? get data with deck id and time span


commit c858ae1d6b8aac54cbed9dc6edb5b121fcc2a598
Merge: 1b50079 58cd4f2
Author: Hui.Chen <hui.chen@qyidea.com>
Date: ? Mon Dec 21 13:44:31 2015 +0800


? ? Merge branch 'feature-update' of git.qyidea.com:hui.chen/hearthdap-front


commit 1b500792ba2ae9bdc2b2a6e4b7203e6ec0b877cd
Author: Hui.Chen <hui.chen@qyidea.com>


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git commit -m "add index of help"
[guoxun f3790fd] add index of help
?3 files changed, 496 insertions(+)
?create mode 100644 application/controllers/helpIndex.php
?create mode 100644 application/views/helpIndex.tpl
?create mode 100644 assets/images/helpView.jpg


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git branch
* guoxun
? master


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git branch -a
* guoxun
? master
? remotes/origin/HEAD -> origin/master
? remotes/origin/feature-update
? remotes/origin/guoxun
? remotes/origin/master


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git log
commit f3790fd13a597e61b8316bfcd51b9acd2fe920d3
Author: guoxun <262091291@qq.com>
Date: ? Mon Mar 7 17:00:23 2016 +0800


? ? add index of help


commit f258c36490d35ff956d47956bfb67bfc45eaf940
Merge: d1a272e 30ae67c
Author: Hui.Chen <hui.chen@qyidea.com>
Date: ? Thu Jan 14 16:32:26 2016 +0800


? ? Merge branch 'dev' of git.qyidea.com:hui.chen/hearthdap-front


commit d1a272e9d568c5f60c0e1f5eda76765d5d67c090
Author: Hui.Chen <hui.chen@qyidea.com>
Date: ? Thu Jan 14 16:31:22 2016 +0800


? ? remove authorized_keys


commit 30ae67c27ccb6e72552e8f08f51e69de0125bef0
Author: sjh <jiahe404@163.com>
Date: ? Tue Jan 12 16:21:11 2016 +0800


:


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git push origin guoxun
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (10/10), done.
Writing objects: 100% (10/10), 94.23 KiB | 0 bytes/s, done.
Total 10 (delta 6), reused 0 (delta 0)
To git@git.qyidea.com:hui.chen/hearthdap-front.git
? ?f258c36..f3790fd ?guoxun -> guoxun


二.解決遠端沖突問題:

1.這里有個暴力解法 在保證你本地已經是你當前所需的結果,那么可以直接刪除遠端。

http://git.qyidea.com/hui.chen/hearthdap-front/branches

在這個網站上直接刪除了遠端分支,解決了問題· 也可以用?git push origin :guoxun 來刪除遠端 本質上,不是刪除,是覆蓋遠端。

操作記錄如下:

admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git status
On branch guoxun
nothing to commit, working directory clean


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git push origin guoxun
To git@git.qyidea.com:hui.chen/hearthdap-front.git
?! [rejected] ? ? ? ?guoxun -> guoxun (non-fast-forward)
error: failed to push some refs to 'git@git.qyidea.com:hui.chen/hearthdap-front.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.


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git status
On branch guoxun
nothing to commit, working directory clean


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git log
commit c23dfd60efbea5fff0dcf2bfc6d75067e78b8d9b
Author: guoxun <262091291@qq.com>
Date: ? Sat Mar 12 18:35:44 2016 +0800


? ? add function email expression test


commit 849c3d30fe87bbe843a8c9ac5e1ec6aea903e3fc
Author: guoxun <262091291@qq.com>
Date: ? Fri Mar 11 23:27:48 2016 +0800


? ? add function register


commit 07efb997eb1e3835abee98dcba4a0f5cfc2397c8
Author: guoxun <262091291@qq.com>
Date: ? Tue Mar 8 13:02:18 2016 +0800


? ? add help index by modal


commit c5098e76102be9af515b1503bdc5ca20585726f7
Author: guoxun <262091291@qq.com>
Date: ? Tue Mar 8 00:12:07 2016 +0800


? ? debug index of help


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git status
On branch guoxun
nothing to commit, working directory clean


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git fetch


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git branch -a
* guoxun
? master
? remotes/origin/HEAD -> origin/master
? remotes/origin/dev
? remotes/origin/feature-update
? remotes/origin/guoxun
? remotes/origin/master
? remotes/origin/sjhtest


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git branch -a
* guoxun
? master
? remotes/origin/HEAD -> origin/master
? remotes/origin/dev
? remotes/origin/feature-update
? remotes/origin/guoxun
? remotes/origin/master
? remotes/origin/sjhtest


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git branch -a
* guoxun
? master
? remotes/origin/HEAD -> origin/master
? remotes/origin/dev
? remotes/origin/feature-update
? remotes/origin/guoxun
? remotes/origin/master
? remotes/origin/sjhtest


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git push origin :guoxun
error: unable to delete 'guoxun': remote ref does not exist
error: failed to push some refs to 'git@git.qyidea.com:hui.chen/hearthdap-front.git'


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git branch -a
* guoxun
? master
? remotes/origin/HEAD -> origin/master
? remotes/origin/dev
? remotes/origin/feature-update
? remotes/origin/guoxun
? remotes/origin/master
? remotes/origin/sjhtest


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ git push origin guoxun
Counting objects: 38, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (38/38), done.
Writing objects: 100% (38/38), 182.73 KiB | 0 bytes/s, done.
Total 38 (delta 29), reused 0 (delta 0)
To git@git.qyidea.com:hui.chen/hearthdap-front.git
?* [new branch] ? ? ?guoxun -> guoxun


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$ ^C


admin@guoxun MINGW64 /guoxungit/hearthdap-front (guoxun)
$

總結

以上是生活随笔為你收集整理的git学习心得的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。