Git 使用備忘

2021-06-03 14:51:19 字數 1049 閱讀 5015

簡單的 git 使用教程。

從服務拷貝**副本到本地(類似 svn checkout)

新增本機檔案到伺服器

這個好像沒直接的命令可以檢視,可以去 git **的根目錄下的 .git/config 裡去看。

切換分支。一般在切換分支前需要 git pull 更新到最新。這個命令,還有另外乙個用處,當你想恢復乙個檔案時候,可以使用 git checkout xx (你還可以先把這個檔案先刪掉)。

git branch name :建立新的分支(name)。

git branch -a :檢視所有的分支資訊。

git branch -d name :刪除本地分支 name。

git push origin :name :刪除遠端分支 name。

和 svn diff 類似的東西。

找到2個分支最近一次的公共 commit 。

把 branch-a 合併到當前分支。

建立倉庫。如果是在遠端的伺服器上,一般要用 git init --bare 來建立倉庫。 建立倉庫的話需要配置一下倉庫訪問許可權,否則別人無法提交**到你建立的倉庫:

[core]

repositoryformatversion = 0

filemode = true

bare = true

sharedrepository = 1

[receive]

enynonfastforwards = true

在倉庫**目錄下可以新建乙個叫 .gitignore 的檔案來配置提交**時忽略的檔案型別:

*.class

*.apk

*.ap_

*.swp

br#gen/

doc/

local.properties

proguard/

build.xml

Git使用備忘

etc gitconfig 檔案 系統中對所有使用者都普遍適用的配置。若使用 git config 時用 system 選項,讀寫的就是這個檔案。gitconfig 檔案 使用者目錄下的配置檔案只適用於該使用者。若使用 git config 時用 global 選項,讀寫的就是這個檔案。當前專案的 ...

Git使用備忘

對於已經commit的,先使用 git rm r cached ignore file 來刪除快取,然後才可以使用 git ignore 使用gitignore來忽略檔案。s1 touch gitignore 建立gitignore隱藏檔案 s2 vim gitignore 編輯檔案,加入指定檔案 ...

git使用備忘

1.未push,直接使用git commit amend 可以修改 2.已push,使用git commit amend後,使用 git push origin head refs for 分支名或master no thin 使用git commit amend 將裡面的change id改為ge...