1.在github官網(wǎng)( )注冊一個賬號;

10多年的衡陽縣網(wǎng)站建設(shè)經(jīng)驗,針對設(shè)計、前端、開發(fā)、售后、文案、推廣等六對一服務(wù),響應(yīng)快,48小時及時工作處理。全網(wǎng)營銷推廣的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動調(diào)整衡陽縣建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯(lián)從事“衡陽縣網(wǎng)站設(shè)計”,“衡陽縣網(wǎng)站推廣”以來,每個客戶項目都認真落實執(zhí)行。
2.登錄賬號,創(chuàng)建一個新的倉庫,如下圖
3.填寫倉庫名稱,配置倉庫相關(guān)信息
4.完成創(chuàng)建后,copy倉庫地址備用
5.在本地創(chuàng)建一個文件夾作為git本地倉庫文件夾,然后打開終端執(zhí)行以下命令
cd 到git本地倉庫文件夾中
git clone '上面copy的地址'
此時在git本地倉庫文件夾中會看到一個README文件,然后將自己的工程根目錄下的所有文件移到git本地倉庫文件夾中,然后在終端執(zhí)行以下命令
git add . //添加所有文件
git commit -m '添加了所有文件提交到本地倉庫' //提交
git push -u origin master //推送到遠程git倉庫
此時去github網(wǎng)頁查看自己提交的項目,大功告成!
如果在創(chuàng)建倉庫時,未勾選.gitignore選項,則在使用git的過程中push時,改動的文件中會頻繁出現(xiàn)UserInterfaceState.xcuserstate文件。原因就是未使用.gitignore文件(就是git軟件要忽略的文件列表,如果要忽略某些文件,在Git工作區(qū)的根目錄下創(chuàng)建一個特殊的.gitignore文件,然后把要忽略的文件名填進去,Git就會自動忽略這些文件。),如何創(chuàng)建呢?接下來用我的實際經(jīng)驗來給大家解決這個小問題咯????
cd到你的工程目錄下,然后 touch .gitignore
vi .gitigonre
project.xcworkspace
xcuserdata
UserInterfaceState.xcuserstate
project.xcworkspace/
xcuserdata/
UserInterface.xcuserstate
4.保存退出
然后執(zhí)行命令
git add .
git ommit -m '描述'
git push
成功后就不會出現(xiàn)UserInterfaceState.xcuserstate這種文件啦!
如果還是會出現(xiàn),則用以下命令
1.git status
查看當前狀態(tài),會出現(xiàn)一個modifidy: UserInterfaceState.xcuserstate文件的路徑,咱們copy這個路徑;
Gitting開始
而不是絮絮叨叨的git的理論,我們要潛水的權(quán)利,并嘗試一下。我們將創(chuàng)建一個新的Xcode項目,并嘗試Git源控制的某一天到一天的基礎(chǔ)上,你通常會做一些典型任務(wù)。
所以火起來的Xcode,創(chuàng)建一個新的項目,或去FileNewProject,挑選單一視圖的應(yīng)用程序模板從iOSApplication“菜單,并點擊Next。
現(xiàn)在單擊“下一步”。下面的對話框,讓你選擇在哪里保存你的項目。選擇的位置,確保“創(chuàng)建這個項目的本地git倉庫”,然后再單擊“創(chuàng)建”按鈕。一旦你這樣做,單擊“創(chuàng)建”按鈕。
通過檢查,Xcode將創(chuàng)建一個空的Git存儲庫,并使用您第一次提交您的新項目的基礎(chǔ)上。嗯,這正是我們想要的!
首先在本地建立一個文件夾命名為manager.
然后打開終端,輸入cd ,把文件夾拖到cd后面,回車,輸入pwd之后再回車,進入到manager文件夾下,然后開始git指令,第一步git init,在本地建立一個空倉庫。之后建立一個文件名為mian.c的文件,touch main.c。在mian.c中手動輸入一些文字,然后輸入git status查看狀態(tài)。
main.c為紅色說明main.c被編輯過了,現(xiàn)在繼續(xù)編輯準備提交輸入int b = 2.現(xiàn)在的main.c是存在工作區(qū)的,下一步是要把修改的文件添加到暫存區(qū),git add main.c,不過~回車之后并沒有什么變化,繼續(xù)操作,是把暫存區(qū)里的main.c添加到本地倉庫中,git
commit main.c
-m添加了b,如果不添加-m的話會少一個配置,會進入到一個vim模式(不可編輯),并且提示你添加一個文件,這時候需要先輸入i,下面會出現(xiàn)一個insert,然后編輯你提交的信息,然后按esc鍵,在按:wq,保存并退出。所以為了不要這么麻煩,直接在后面加上-m和注釋就可以了
這樣說明已經(jīng)把修改的內(nèi)容成功提交到本地倉庫了!
下一步,如果想回到某個版本怎么辦?首先git log,看一下日志信息,或者git reflog.
git log下可以看到一個40位的哈希值,這里你可以把它當做序列號就好了,也就是你的版本號。而在git reflog下,只顯示你版本號的前7位,其實用的時候就用這前7位就夠了。如果想回到某個版本,只需要git reset --hard 版本號就可以了在打開你的main.c你會發(fā)現(xiàn)他回到了你需要的地方.還有一個指令可以看到你修改的地方:首先編輯你的main.c,然后輸入git diff mian.c,你會看到效果的.
好了,git建立本地倉庫就到這里,還有很多命令沒介紹到,以后用的時候還要多多練習(xí)!
1、安裝git,官網(wǎng)有安裝教程;
2、在新建項目到時候會有如下選項
如果創(chuàng)建項目到時候,沒有選擇創(chuàng)建repository,需要以下步驟進行設(shè)置
1)進入到該項目到目錄下
$ cd Matchismo
2)找到xcuserstate,并設(shè)置到忽略文件夾中
$ find . 找到隱藏文件xcuserstate,用來記錄UI的情況,可以不使用git來提交
.
./.DS_Store
./Matchismo
./Matchismo/.DS_Store
./Matchismo/Base.lproj
./Matchismo/Base.lproj/Main.storyboard
./Matchismo/Card.h
./Matchismo/Card.m
./Matchismo/CardGameAppDelegate.h
./Matchismo/CardGameAppDelegate.m
./Matchismo/CardGameViewController.h
./Matchismo/CardGameViewController.m
./Matchismo/Deck.h
./Matchismo/Deck.m
./Matchismo/en.lproj
./Matchismo/en.lproj/InfoPlist.strings
./Matchismo/Images.xcassets
./Matchismo/Images.xcassets/AppIcon.appiconset
./Matchismo/Images.xcassets/AppIcon.appiconset/Contents.json
./Matchismo/Images.xcassets/cardBack.imageset
./Matchismo/Images.xcassets/cardBack.imageset/cardBack-1.png
./Matchismo/Images.xcassets/cardBack.imageset/cardBack.png
./Matchismo/Images.xcassets/cardBack.imageset/Contents.json
./Matchismo/Images.xcassets/cardFront.imageset
./Matchismo/Images.xcassets/cardFront.imageset/cardFront-1.png
./Matchismo/Images.xcassets/cardFront.imageset/cardFront.png
./Matchismo/Images.xcassets/cardFront.imageset/Contents.json
./Matchismo/Images.xcassets/Image.imageset
./Matchismo/Images.xcassets/Image.imageset/Contents.json
./Matchismo/Images.xcassets/LaunchImage.launchimage
./Matchismo/Images.xcassets/LaunchImage.launchimage/Contents.json
./Matchismo/main.m
./Matchismo/Matchismo-Info.plist
./Matchismo/Matchismo-Prefix.pch
./Matchismo/model
./Matchismo/model/CardMatchingGame.h
./Matchismo/model/CardMatchingGame.m
./Matchismo/PlayingCard.h
./Matchismo/PlayingCard.m
./Matchismo/PlayingCardDeck.h
./Matchismo/PlayingCardDeck.m
./Matchismo.xcodeproj
./Matchismo.xcodeproj/project.pbxproj
./Matchismo.xcodeproj/project.xcworkspace
./Matchismo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
./Matchismo.xcodeproj/project.xcworkspace/xcuserdata
./Matchismo.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad
./Matchismo.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate
./Matchismo.xcodeproj/xcuserdata
./Matchismo.xcodeproj/xcuserdata/chris.xcuserdatad
./Matchismo.xcodeproj/xcuserdata/chris.xcuserdatad/xcdebugger
./Matchismo.xcodeproj/xcuserdata/chris.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
./Matchismo.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes
./Matchismo.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/Matchismo.xcscheme
./Matchismo.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/xcschememanagement.plist
./MatchismoTests
./MatchismoTests/en.lproj
./MatchismoTests/en.lproj/InfoPlist.strings
./MatchismoTests/MatchismoTests-Info.plist
./MatchismoTests/MatchismoTests.m
3)將文件導(dǎo)入到gitignore
bogon:Matchismo chris$ echo Matchismo.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate .gitignore
bogon:Matchismo chris$ cat .gitignore
Matchismo.xcodeproj/project.xcworkspace/xcuserdata/chris.xcuserdatad/UserInterfaceState.xcuserstate
4)在項目文件目錄下 執(zhí)行指令:git init
bogon:Matchismo chris$ git init
Initialized empty Git repository in /Users/chris/developer/Matchismo/.git/
5)當前目錄添加到git
bogon:Matchismo chris$ git add .
bogon:Matchismo chris$ git commit -m "Now under sorce control” 第一次提交的注釋
[master (root-commit) 3eb6864] Now under sorce control
37 files changed, 1643 insertions(+)
create mode 100644 .gitignore
create mode 100644 Matchismo.xcodeproj/project.pbxproj
create mode 100644 Matchismo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
create mode 100644 Matchismo.xcodeproj/xcuserdata/chris.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
create mode 100644 Matchismo.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/Matchismo.xcscheme
create mode 100644 Matchismo.xcodeproj/xcuserdata/chris.xcuserdatad/xcschemes/xcschememanagement.plist
create mode 100644 Matchismo/Base.lproj/Main.storyboard
create mode 100644 Matchismo/Card.h
create mode 100644 Matchismo/Card.m
create mode 100644 Matchismo/CardGameAppDelegate.h
create mode 100644 Matchismo/CardGameAppDelegate.m
create mode 100644 Matchismo/CardGameViewController.h
create mode 100644 Matchismo/CardGameViewController.m
create mode 100644 Matchismo/Deck.h
create mode 100644 Matchismo/Deck.m
create mode 100644 Matchismo/Images.xcassets/AppIcon.appiconset/Contents.json
create mode 100644 Matchismo/Images.xcassets/Image.imageset/Contents.json
create mode 100644 Matchismo/Images.xcassets/LaunchImage.launchimage/Contents.json
create mode 100644 Matchismo/Images.xcassets/cardBack.imageset/Contents.json
create mode 100644 Matchismo/Images.xcassets/cardBack.imageset/cardBack-1.png
create mode 100644 Matchismo/Images.xcassets/cardBack.imageset/cardBack.png
create mode 100644 Matchismo/Images.xcassets/cardFront.imageset/Contents.json
create mode 100644 Matchismo/Images.xcassets/cardFront.imageset/cardFront-1.png
create mode 100644 Matchismo/Images.xcassets/cardFront.imageset/cardFront.png
create mode 100644 Matchismo/Matchismo-Info.plist
create mode 100644 Matchismo/Matchismo-Prefix.pch
create mode 100644 Matchismo/PlayingCard.h
create mode 100644 Matchismo/PlayingCard.m
create mode 100644 Matchismo/PlayingCardDeck.h
create mode 100644 Matchismo/PlayingCardDeck.m
create mode 100644 Matchismo/en.lproj/InfoPlist.strings
create mode 100644 Matchismo/main.m
create mode 100644 Matchismo/model/CardMatchingGame.h
create mode 100644 Matchismo/model/CardMatchingGame.m
create mode 100644 MatchismoTests/MatchismoTests-Info.plist
create mode 100644 MatchismoTests/MatchismoTests.m
create mode 100644 MatchismoTests/en.lproj/InfoPlist.strings
bogon:Matchismo chris$
之前用svn的,但是愕然發(fā)現(xiàn)好多公司都開始用git ,一開始不知道為什么,想想那么多公司用它,肯定有它的優(yōu)點啥,帶著好奇的心態(tài),慢慢開始去研究它,由于我們公司,就我一個iOS,所以暫時好多git的好多優(yōu)點都是持續(xù)發(fā)掘的,本文也會持續(xù)更新中····
我們用的都是Mac,所以可以直接通過homebrew安裝Git,具體方法請參考homebrew的文檔:
然后再檢查
然后,設(shè)置你的個人信息
注意'git config'命令的'--global'參數(shù),用了這個參數(shù),表示你這臺機器上所有的Git倉庫都會使用這個配置,當然也可以對某個倉庫指定不同的用戶名和Email地址。
2-1、可以新建一個文件夾,mkdir testGit, 然后cd testGit
2-2、增加你需要改變的東西,放到testGit中去,添加到倉庫中去
2-3、提交到倉庫中去 -m “這里面是需要注釋的內(nèi)容”
2-4、接下來就是看,你的遠程倉庫建在什么地方啦,我在github 和 coding 上都有,個人認為剛開始在coding 上使用還是不錯的
2-5、把內(nèi)容推送到遠程庫上
2-6、然后每次用之前
實際上現(xiàn)在到目前為止就可以開始用起來啦,當然分支管理這個大部分我們后期在討論。
常用的命令
2-7、建立分支并切換
2-8、合并分支
工作區(qū)-----倉庫----遠程倉庫(git add; git commit ; git push )
Swap file ".git/.MERGE_MSG.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)born:
4-1(答)解決方法:
解決:
相應(yīng)的 git pull
自動合并失敗。由于在同一行進行了修改,所以產(chǎn)生了沖突。
在沖突處
然后重新提交
iOS 開發(fā),新電腦,新環(huán)境。用Xcode,git,但是不喜歡Xcode自帶的source tree,又但是每次git pull 、push相關(guān)操作都得把項目文件拖進終端,這樣就麻煩了很多。
所以記錄了Xcode迅速打開終端(Terminal)
1.新建個.sh文件 ,執(zhí)行一下腳本
#!/bin/sh
if [ -n "$XcodeProjectPath" ]; then
open -a Terminal "$XcodeProjectPath"/..
else
open -a Terminal "$XcodeWorkspacePath"/..
fi
2.打開 Xcode 的 Behavior 界面, 如下所示:
然后點擊如上圖的加號, 出現(xiàn)新建的 Behavior:
選擇你剛剛新建的.sh文件,如果文件是灰色的,不可選擇點擊,打開終端,執(zhí)行chmod? 777? 你的.sh文件
chmod +x your_script_name.sh? 這玩意好像不起作用,大家注意下
然后添加 勾選run,前面設(shè)置個快捷鍵 command+T,就完成了
文章名稱:關(guān)于ios開發(fā)git使用教程的信息
本文路徑:http://chinadenli.net/article17/dsejcdj.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供用戶體驗、手機網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站、品牌網(wǎng)站設(shè)計、網(wǎng)站收錄、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)