[面試題] git push origin master
每天練一點面試題,避免要面試的時候,考官跟你彼此面面相覷尷尬吧!
這個指令假定你的本機有個分支名叫:master ,他會幫你在遠端分支也建立一個叫 master 的分支。
通常會在我們本機建立新分支,而 GitHub 上沒有這個分支時,當你 git push 上去,他就會說:sorry 遠端沒有分支喔,要不要建一個,這個時候就會用到。
在我的第一個專案裡,有很多需要碰到資料庫的事情(因為我們選了一個CRUD有夠少的主題(?))當手撈過資料庫下指令後,就會知道Migration是多麼棒的存在 !
為此我願意為它單獨寫一篇你就知道他在我心中多麼重要。Migration是什麼呢?我個人私自認定他就是個寫入資料庫前的翻譯檔+資料庫版的 git 版控(?)有了它,我們可以藉由他產生的時間戳記知道每個組員到底在資料庫裡面做了什麼,這邊有個重點:每個 Migration 只能執行一次。
這幾天都在狂踩雷,當一個人在上課或做小作品的時候,我只會使用以下的git 指令:
git init : 初始化,然後把這個檔案交給 git 做版控git branch : 查看現在有哪些分支。git add . : 把你這段時間在工作區修改的檔案先加到暫存區,那個小數點是這個位置裡所有的資料。git commit -m “你要儲存的內容明細”:這個是你這次要存到儲存區的內容,以及做了哪些事的說明。
一次只要專注於一個小事情就可以了,所以今天我不要一口氣說 model 的全部關聯,我就只說一個一對一關聯。
不知道大家知不知道,其實你跟大家一起做專案時,在各自的本機的 database 都是獨立的,所以就算別人在他的資料庫裡新增很多資料,在你這邊一樣是什麼都沒有,這時候就要靠在 db 裡面的 Schema 跟 migrate 幫你記錄彼此之間增加或減少什麼資料表跟欄位。
另外你也不知道別人在他負責的那張票的過程裡,是不是有新增什麼 gem 來用,以及有沒有灌什麼新的前端套件。