最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

利用git提交代碼的方法步驟

 更新時間:2020年08月13日 10:37:13   作者:jackchensir  
這篇文章主要介紹了利用git提交代碼的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

一、首先需要下載git

  查看電腦是否安裝git,打開終端,輸入git,回車如果輸出如下,則代表已安裝了git

如果未安裝,則會輸出:

按照提示輸入:sudo apt-get install git即可安裝!!或者到此處下載:git下載,pkg包下載完成,雙擊安裝。

輸入命令:git --version 可查看當(dāng)前git版本

二.安裝后需要一些配置

配置用戶名和郵箱:

$ git config --global user.name "Your Name" 
$ git config --global user.email "email@example.com" 

使用 --global 修飾后設(shè)置的全局的用戶,如果設(shè)置單個項目的用戶,可cd到項目根目錄下,執(zhí)行如下命令:

$ git config user.name "Your Name" 
$ git config user.email "email@example.com" 

使用命令:git config --list 可查看當(dāng)前用戶信息以及其他的一些信息

$ git config --list 
core.excludesfile=/Users/mac/.gitignore_global 
difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE" 
difftool.sourcetree.path= 
mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED" 
mergetool.sourcetree.trustexitcode=true 
http.postbuffer=524288000 
https.postbuffer=524288000 
user.email=你的郵箱@qq.com 
user.name=你的用戶名 
macdeMacBook-Pro:~ Artron_LQQ$

三.建立本地git倉庫

1. cd到你的項目目錄

$ cd /Users/cjk/Desktop/myShop

2. 然后,輸入git命令:

$ git init 

輸出如下:

$ git init 
Initialized empty Git repository in /Users/cjk/Desktop/GitTest/.git/ 

創(chuàng)建了一個空的本地倉庫.

3.將項目的所有文件添加到緩存中:

$ git add . 

git add . (注意,后面有個點)表示添加目錄下所有文件到緩存庫,如果只添加某個文件,只需把 . 換成你要添加的文件名即可;

4.將緩存中的文件Commit到git庫

git commit -m "添加你的注釋,一般是一些更改信息"

下面是第一次提交時的輸出:

$ git commit -m "添加項目"
[master (root-commit) 3102a38] 添加項目
 18 files changed, 1085 insertions(+)
 create mode 100644 GitTest.xcodeproj/project.pbxproj
 create mode 100644 GitTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata
 create mode 100644 GitTest.xcodeproj/project.xcworkspace/xcuserdata/Artron_LQQ.xcuserdatad/UserInterfaceState.xcuserstate
 create mode 100644 GitTest.xcodeproj/xcuserdata/Artron_LQQ.xcuserdatad/xcschemes/GitTest.xcscheme
 create mode 100644 GitTest.xcodeproj/xcuserdata/Artron_LQQ.xcuserdatad/xcschemes/xcschememanagement.plist
 create mode 100644 GitTest/AppDelegate.h
 create mode 100644 GitTest/AppDelegate.m
 create mode 100644 GitTest/Assets.xcassets/AppIcon.appiconset/Contents.json
 create mode 100644 GitTest/Base.lproj/LaunchScreen.storyboard
 create mode 100644 GitTest/Base.lproj/Main.storyboard
 create mode 100644 GitTest/Info.plist
 create mode 100644 GitTest/ViewController.h
 create mode 100644 GitTest/ViewController.m
 create mode 100644 GitTest/main.m
 create mode 100644 GitTestTests/GitTestTests.m
 create mode 100644 GitTestTests/Info.plist
 create mode 100644 GitTestUITests/GitTestUITests.m
 create mode 100644 GitTestUITests/Info.plist

或者不添加注釋 git commit ,但是這樣會進入vim(vi)編輯器

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Changes to be committed:
#    modified:  LQQCircleShowImage.xcodeproj/project.pbxproj
#    modified:  LQQCircleShowImage/TableViewCell.m
#
~                                        
~                                        
~                                        
~                                        
~                                        
~                                        
~                                        
~                                        
~                                        
~                                        
~                                        
~                                        
~                                        
~                                        
~                                        
"~/Desktop/LQQCircleShowImage/.git/COMMIT_EDITMSG" 8L, 292C

在這里可以輸入更改信息,也可以不輸入,然后 按住 shift + : ,輸入wq 即可保存信息并退出vim編輯器;

四,建立遠程庫

在一些代碼托管平臺創(chuàng)建項目,例如github或者開源中國社區(qū),這里已開源中國社區(qū)為例;

創(chuàng)建項目后,會生成一個HTTPS鏈接,如下:

https://git.oschina.net/liuqiqiang/gitTest.git

五,將本地的庫鏈接到遠

終端中輸入: git remote add originHTTPS鏈接

$ git remote add origin https://git.oschina.net/liuqiqiang/gitTest.git 

六.上傳代碼到遠程庫,上傳之前最好先Pull一下,再執(zhí)行命令: git pull origin master

輸出:

$ git pull origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From https://git.oschina.net/liuqiqiang/gitTest
 * branch      master   -> FETCH_HEAD
 * [new branch]   master   -> origin/master
Merge made by the 'recursive' strategy.
 README.md | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 README.md

即pull成功,

七.接著執(zhí)行:git push origin master

完成后輸出:

$ git push origin master
Counting objects: 34, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (29/29), done.
Writing objects: 100% (34/34), 15.63 KiB | 0 bytes/s, done.
Total 34 (delta 3), reused 0 (delta 0)
To https://git.oschina.net/liuqiqiang/gitTest.git
  5e2dda1..537ecfe master -> master

即將代碼成功提交到遠程庫!!!

注:如果pull之后出現(xiàn) “ refusing to merge unrelated histories ”這句,就證明你合并pull兩個不同的項目

出現(xiàn)的問題如何去解決fatal: refusing to merge unrelated histories

我在Github新建一個倉庫,寫了License,然后把本地一個寫了很久倉庫上傳。

先pull,因為兩個倉庫不同,發(fā)現(xiàn)refusing to merge unrelated histories,無法pull

因為他們是兩個不同的項目,要把兩個不同的項目合并,git需要添加一句代碼,在git pull,這句代碼是在git 2.9.2版本發(fā)生的,最新的版本需要添加--allow-unrelated-histories

假如我們的源是origin,分支是master,那么我們 需要這樣寫git pull origin master --allow-unrelated-histories需要知道,我們的源可以是本地的路徑

接著到你的遠程庫查看,提交前:

提交成功后:

注意:操作的時候,指令不要輸錯了!!!!

下面這個是輸錯了 orgin的輸出:

git pull orgin master
fatal: 'orgin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

正確的應(yīng)該是origin!!

如果在push的時候有如下輸出:

$ git push -u origin master
To https://git.oschina.net/liuqiqiang/LQQCircleShowImage.git
 ! [rejected]    master -> master (fetch first)
error: failed to push some refs to 'https://git.oschina.net/liuqiqiang/LQQCircleShowImage.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.

看提示可知道,需要先pull一下,即執(zhí)行一次:git pull origin master

然后再執(zhí)行:git push origin master

分支管理

新建分支

$ git branch newbranch

查看分支

$ git branch

輸出:

* master
newbranch

*代表當(dāng)前所在的分支

切換分支

$ git checkout new branch

輸出

Switched to branch 'newbranch'

切換后可用git branch查看是否切換到當(dāng)前分支

master
* newbranch

提交改動到當(dāng)前分支

$ git add .
$ git commit -a

可使用git status查看提交狀態(tài)

接著切回主分支

$ git checkout master

輸出:

Switched to branch 'master'

將新分支提交的改動合并到主分支上

$ git merge newbranch

輸出:

Updating cc73a48..93a1347
Fast-forward
GitTest.xcodeproj/project.pbxproj | 9 +++++++++
.../UserInterfaceState.xcuserstate | Bin 0 -> 7518 bytes
GitTest/test.h | 13 +++++++++++++
GitTest/test.m | 13 +++++++++++++
4 files changed, 35 insertions(+)
create mode 100644 GitTest.xcodeproj/project.xcworkspace/xcuserdata/Artron_LQQ.xcuserdatad/UserInterfaceState.xcuserstate
create mode 100644 GitTest/test.h
create mode 100644 GitTest/test.m

這里我提交了兩個文件,即:test.h和test.m

如果合并后產(chǎn)生沖突,可輸入以下指令查看沖突:

$ git diff

修改之后,再次提交即可;

接下來,就可以push代碼了:

$ git push -u origin master

這時可能需要你輸入你的github用戶名和密碼,按照提示輸入即可;

刪除分支

$ git branch -D newbranch

輸出

Deleted branch newbranch (was 93a1347).

以上就是最簡單的github操作了,也是在網(wǎng)上看著學(xué)的,注意在實際操作中多加練習(xí),代碼這東西,剛開始橋的多了也就記下了!

到此這篇關(guān)于利用git提交代碼的方法步驟的文章就介紹到這了,更多相關(guān)git 提交代碼內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 級聯(lián)分類器算法原理解析

    級聯(lián)分類器算法原理解析

    這篇文章主要為大家介紹了級聯(lián)分類器算法的原理解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-05-05
  • 一個批量編碼轉(zhuǎn)換及ASP/JS加解密/簡繁轉(zhuǎn)換的工具

    一個批量編碼轉(zhuǎn)換及ASP/JS加解密/簡繁轉(zhuǎn)換的工具

    一個批量編碼轉(zhuǎn)換及ASP/JS加解密/簡繁轉(zhuǎn)換的工具...
    2007-05-05
  • 郵件的協(xié)議及服務(wù)器工作原理

    郵件的協(xié)議及服務(wù)器工作原理

    本系列教程將會講解郵件的基本常識與概念,郵件的協(xié)議以及郵件服務(wù)器的工作原理,然后用JavaMail發(fā)送郵件的基本實現(xiàn)過程,郵件內(nèi)嵌圖片等高級郵件技巧。相信大家看完后,一定會有所收獲
    2022-05-05
  • windows開發(fā)記事本程序紀(jì)實(一)界面篇

    windows開發(fā)記事本程序紀(jì)實(一)界面篇

    這將是一個系列博文,后面會繼續(xù)補充邏輯功能的開發(fā)的步驟。本節(jié)主要實現(xiàn)記事本的主界面設(shè)計,包括主界面窗口的構(gòu)建、菜單的加入。雖然都是一些基本的操作,但是還是想將這些基本步驟完整地記錄下來,以便后續(xù)驗證。
    2014-08-08
  • GIT如何修改賬號密碼重新登錄和保存密碼

    GIT如何修改賬號密碼重新登錄和保存密碼

    這篇文章主要介紹了GIT如何修改賬號密碼重新登錄和保存密碼問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • http協(xié)議詳解(超詳細(xì))

    http協(xié)議詳解(超詳細(xì))

    HTTP協(xié)議(HyperText Transfer Protocol,超文本傳輸協(xié)議)是用于從WWW服務(wù)器傳輸超文本到本地瀏覽器的傳送協(xié)議。
    2011-08-08
  • Typora?1.4.8激活?2022最新Typora破解激活使用教程

    Typora?1.4.8激活?2022最新Typora破解激活使用教程

    Typora?for?mac?是一款簡潔的markdown編輯器、寫作軟件。它去除了預(yù)覽窗口,模式切換器,語法符號以及所有其他不必要的干擾,今天給大家分享Typora?1.4.8?最新Typora破解激活使用教程,感興趣的朋友跟隨小編一起看看吧
    2023-01-01
  • Git使用小技巧之回滾與撤銷詳解

    Git使用小技巧之回滾與撤銷詳解

    這篇文章主要給大家介紹了關(guān)于Git使用小技巧之回滾與撤銷的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用Git具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-07-07
  • HTTP 2.0 詳細(xì)介紹

    HTTP 2.0 詳細(xì)介紹

    本文主要介紹 HTTP 2.0的知識,這里整理了詳細(xì)的資料,并對HTTP2.0的知識做了詳解,有需要的小伙伴可以參考下
    2016-09-09
  • 淺析hosts 文件的作用及修改 hosts 文件的方法

    淺析hosts 文件的作用及修改 hosts 文件的方法

    hosts是一個沒有擴展名的系統(tǒng)文件,其基本作用就是將一些常用的網(wǎng)址域名與其對應(yīng)的 IP 地址建立一個關(guān)聯(lián)“ 數(shù)據(jù)庫 ”。接下來通過本文給大家介紹hosts 文件的作用及修改 hosts 文件的方法,需要的朋友參考下吧
    2018-01-01

最新評論

鹤峰县| 崇信县| 静安区| 迁西县| 疏附县| 永胜县| 德保县| 望江县| 佛学| 万源市| 连江县| 宽城| 麻城市| 汨罗市| 乌拉特后旗| 上思县| 武鸣县| 丹东市| 沈丘县| 平罗县| 敦化市| 云南省| 扎赉特旗| 临高县| 洞头县| 巫山县| 贺兰县| 汉寿县| 响水县| 松阳县| 通州区| 宿迁市| 浦东新区| 綦江县| 电白县| 海南省| 堆龙德庆县| 常州市| 金沙县| 宕昌县| 彝良县|