特黄特色三级在线观看免费,看黄色片子免费,色综合久,欧美在线视频看看,高潮胡言乱语对白刺激国产,伊人网成人,中文字幕亚洲一碰就硬老熟妇

學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > linux下git的安裝和使用

linux下git的安裝和使用

時(shí)間: 志藝942 分享

linux下git的安裝和使用

  在linux下僅使用了文本界面,所以安裝了個(gè)文本形式的git客戶來(lái)連接github。接下來(lái)是小編為大家收集的linux下git的安裝和使用,希望能幫到大家。

  linux下git的安裝和使用

  1. 安裝git

  我用的是centos系統(tǒng),在使用yum install git時(shí),系統(tǒng)提示沒(méi)有找到git包。所以,僅能通過(guò)以下方法來(lái)安裝git。方法詳見(jiàn):http://www.cnblogs.com/Neddy/archive/2011/02/28/1967548.html。以上方法中有一個(gè)問(wèn)題:方法中給出的git的下載源http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz 似乎無(wú)效了,于是,我在網(wǎng)上的這里下載了個(gè)git的最新安裝包,安裝到了centos上。Linux下git的官方網(wǎng)址為:http://git-scm.com/download ,可能因?yàn)槲揖W(wǎng)慢打不開(kāi),不知道讀者您那里如何。如果打不開(kāi),可以在網(wǎng)上其他地方找找安裝包,應(yīng)該可以找到的。

  2. 使用git連接github

  使用git連接github時(shí),需要將linux下產(chǎn)生的一個(gè)ssh公鑰放到github上。具體步驟詳見(jiàn):http://blog.sina.com.cn/s/blog_6b706e15010199p1.html。主要命令有:

1
ssh-keygen -t rsa -C"mail@mail.com"

  然后系統(tǒng)提示輸入文件保存位置等信息,連續(xù)敲三次回車即可,生成的SSH key文件保存在中~/.ssh/id_rsa.pub文件中。

  用文本編輯工具打開(kāi)該文件,在linux下可以用cat命令顯示id_rsa.pub中的內(nèi)容(cat ~/.ssh/id_rsa.pub),讓后復(fù)制其內(nèi)容。

  接著拷貝.ssh/id_rsa.pub文件內(nèi)的所以內(nèi)容,將它粘帖到github帳號(hào)管理中的添加SSH key界面中。

  注意,使用vim讀取git_home/.ssh/id_rsa.pub中的公鑰內(nèi)容時(shí),可能會(huì)有較多的空格和換行,復(fù)制到github網(wǎng)站上時(shí)必需刪除。所以建議使用cat來(lái)讀取ssh公鑰。將ssh公鑰成功加入github后,可使用命令ssh -T git@github.com來(lái)驗(yàn)證是否成功。如果出現(xiàn)象:hi xxx. You've successfully authenticated, but GitHub does not provide shell access.則說(shuō)明連接成功。

  非常不幸,我未能連接成功。可使用命令ssh -Tv git@github.com來(lái)查找failure的原因。通過(guò)詳細(xì)的debug過(guò)程,我發(fā)現(xiàn)象我把自己的ssh密鑰信息放到了/home/admin/.ssh/下,而測(cè)試時(shí)使用的賬戶是root,尋找ssh密鑰的路徑為root/.ssh,所以permission denied的啦。su到admin下,就可以連接成功啦~~

  3. 使用git與github管理代碼

  3.1 新建一個(gè)repository

  這里就使用github官網(wǎng)上的教程吧。請(qǐng)保證git的版本至少為1.7.10,否則可能無(wú)法成功。詳細(xì)如何使用,請(qǐng)參見(jiàn):https://help.github.com/articles/set-up-git。linux下無(wú)法新建一個(gè)repo,只能對(duì)github中已有的repo進(jìn)行修改。所以,當(dāng)要新建一個(gè)repo時(shí),必須在github.com上新建,再通過(guò)linux下的git向此repo中新添內(nèi)容。

  3.2 修改repo中的代碼

  github的官網(wǎng)上也有修改repo代碼的教程。詳情請(qǐng)參見(jiàn):https://help.github.com/articles/fork-a-repo。簡(jiǎn)要步驟如下:

$git clone https://github.com/username/Spoon-Knife.git
$cd Spoon-Knife
$git add filename.py                          #添加文件到版本庫(kù)
$git commit -m 'add filename.py to src'               #提交,產(chǎn)生版本記錄,注意代碼依然在本地
$vim README.md                             #修改Spoon-Knife中的README.md文件內(nèi)容
$git commit -m 'modify the README.md'                #提交,產(chǎn)生版本記錄,注意代碼依然在本地
$git [remote] rm filename1.py                    #刪除repo中的filename1.py文件
$git commit -m 'delete filename1.py'                  #提交,產(chǎn)生版本記錄,注意代碼依然在本地
$git push origin                             #將修改提交到github上<br>

  3.3 常用git命令

linux下git的安裝和使用

  git help                                 #可查看git的常用命令

  git config --global user.name "Your Name Here"           #設(shè)置commit的署名

  git config --global user.email "your_email@example.com"      #設(shè)置commit的email

  git config [--local|--global|--system] --list/-l          #查看本地的global信息

  git config [--local|--global|--system] --unset[-all] user.name  #刪除user.name信息。如果user.name對(duì)應(yīng)多個(gè)值,可用unset-all來(lái)刪除

  git remote add XXX https://github.com/username/repo_name.git    #設(shè)置github的連接git clone git://github.com/your_account/aimed_repo.git       #復(fù)制一個(gè)repo到本地 git remote -v                               #查看本地設(shè)置的url連接信息 git status                                 #查看當(dāng)前工作的branch git branch                             #查看本地所有的branch git branch -a                           #查看遠(yuǎn)程的所有分支 git branch -d branch_name                        #刪除本地branch_name這一分支 git push origin --delete branch_name                   #刪除名為branch_name的遠(yuǎn)程分支 git checkout branch_name                         #切換到名為branch_name的分支上 git chechout -b branch_name                       #在本地新建一個(gè)名為branch_nam的分支 git diff test_branch_name                        #查看當(dāng)前branch與test_branch_name中代碼的區(qū)別 git mv filename newfilename                      #文件重命名 git push XXX branch_name                        #上傳指定的branch到遠(yuǎn)端 git pull                                  #將遠(yuǎn)程上的版本與本地版本進(jìn)行合并,相當(dāng)于get fetch + git merge git reset --hard                             #將剛才進(jìn)行的git pull所進(jìn)行的操作取消,恢復(fù)本地版本合并前的原貌

linux下git的安裝和使用

  4. 如何刪除github上的repository

  github頁(yè)面上刪除repo的功能比較隱蔽,得在這里表一表。比如,想刪除了一個(gè)名為python的repo。則需先點(diǎn)擊進(jìn)入“python”,單擊“Settings”,找到“Delete this repository”,確認(rèn)刪除即可。注意,github上的repo刪除后就不能恢復(fù)了哦~~

linux下git的安裝和使用
linux下git的安裝和使用

  5. git clone/push時(shí)出現(xiàn)錯(cuò)誤提示:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing ...

  這是由于ssl認(rèn)證出問(wèn)題引起的錯(cuò)誤。有兩種簡(jiǎn)單的解決方法:

  1. 使用命令,成功執(zhí)行后,便可正常使用git clone和git push了

git config --global http.sslVerify false

  2. 使用命令,但每次clone 和 push時(shí)都需要帶上env的部分。

env GIT_SSL_NO_VERIFY=true git clone https://github.com/XXXX/xxxxx.git

  6. git push時(shí)出現(xiàn)錯(cuò)誤non-fast-forward時(shí)怎么辦?(來(lái)自:http://blog.csdn.net/chain2012/article/details/7476493)

  當(dāng)要push代碼到git時(shí),出現(xiàn)提示:

  error:failed to push some refs to ...

  Dealing with “non-fast-forward” errors

  From time to time you may encounter this error while pushing:

  $ git push origin master

  To ../remote/

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

  error: failed to push some refs to '../remote/'

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

  Merge the remote changes before pushing again. See the 'non-fast forward'

  section of 'git push --help' for details.

  This error can be a bit overwhelming at first, do not fear. Simply put, git cannot make the change on the remote without losing commits, so it refuses the push. Usually this is caused by another user pushing to the same branch. You can remedy this by fetching and merging the remote branch, or using pull to perform both at once.

  In other cases this error is a result of destructive changes made locally by using commands like git commit --amend or git rebase. While you can override the remote by adding --force to the push command, you should only do so if you are absolutely certain this is what you want to do. Force-pushes can cause issues for other users that have fetched the remote branch, and is considered bad practice. When in doubt, don’t force-push.

linux下git的安裝和使用

  問(wèn)題(Non-fast-forward)的出現(xiàn)原因在于:git倉(cāng)庫(kù)中已經(jīng)有一部分代碼,所以它不允許你直接把你的代碼覆蓋上去。于是你有2個(gè)選擇方式:

  1,強(qiáng)推,即利用強(qiáng)覆蓋方式用你本地的代碼替代git倉(cāng)庫(kù)內(nèi)的內(nèi)容

  git push -f

  2,先把git的東西fetch到你本地然后merge后再push

  $ git fetch

  $ git merge

  這2句命令等價(jià)于

  $ git pull

  可是,這時(shí)候又出現(xiàn)了如下的問(wèn)題:

linux下git的安裝和使用

  上面出現(xiàn)的 [branch "master"]是需要明確(.git/config)如下的內(nèi)容

  [branch "master"]

  remote = origin

  merge = refs/heads/master

  這等于告訴git2件事:

  1,當(dāng)你處于master branch, 默認(rèn)的remote就是origin。

  2,當(dāng)你在master branch上使用git pull時(shí),沒(méi)有指定remote和branch,那么git就會(huì)采用默認(rèn)的remote(也就是origin)來(lái)merge在master branch上所有的改變

  如果不想或者不會(huì)編輯config文件的話,可以在bush上輸入如下命令行:

  $ git config branch.master.remote origin

  $ git config branch.master.merge refs/heads/master

  之后再重新git pull下。最后git push你的代碼吧。it works now~


看了“linux下git的安裝和使用”還想看:

1.Linux系統(tǒng)上怎樣安裝Git

2.CentOS中Git客戶端怎么安裝

3.怎么在Linux下安裝配置Git服務(wù)

4.CentOS系統(tǒng)怎樣搭建Git版本控制服務(wù)器

2805898