顯示具有 git 標籤的文章。 顯示所有文章
顯示具有 git 標籤的文章。 顯示所有文章

2017年12月8日 星期五

[Android] sync code


  • version control tools
    • repo
      • 簡介: 主要靠 Manifest 來記錄 remote, remote url, 各 project revision等資訊. Manifest 為一個 XML格式的檔案, 記錄各 project git 資訊, 預設的檔案名稱是 default.xml
      • 用法:
        • repo init -u mainfestURL -b branch
          • 通常第一步即透過 mainfest 的 URL得到想要的 manifest資訊, 會產生一個隱藏資料夾 .repo, 通常也可以製作 snapshot.xml
        • repo sync
          • 通常緊接於 repo init 或是透過 snapshot init後, 需要由 repo 通知各 project 進行 git checkout的動作
        • repo upload
          • 較少用到, Manifest 裡 remote 的欄位有設 review url的話, 便會進行 git push 的動作.
    • git
      • git checkout -b localBranchName remoteBranchName
      • git commit
        git commit --amend
        可修改最後一次 commit的內容
      • git push
        將 change 上到 remote
      • git pull
        sync .git 的資訊, 更新 metadata, 檔案等尚未進行 sync
      • 與 repo 可以整合應用, e.g.:
        repo forall -c 'git checkout branch'
      • git config
        設定 git的 configuration, 通常用在設定 user name跟 e-mail
      • git add fileName
      • git reset
      • 僅更改 file status
      • git checkout
      • 會重新抓檔案
      • git update-index --chmod=-x fileName
      • git diff (--cached)
      • git status
        非常常用, 看各個檔案目前是在什麼 status: tracked, untracked,...
  • Sync Android code
    • Setup repo
      • mkdir ~/bin
      • PATH=~/bin:$PATH
      • curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
      • chmod a+x ~/bin/repo
    • Setup git
      • git config --global user.name "Your Name"
      • git config --global user.email "you@example.com"
      • P.S.: 若是在 synology nas上操作的話, 可能遇到
        error: could not lock config file /var/services/homes/yourName/.gitconfig: No such file or directory
        的問題
        • 在 Control Panel->User Account->Advanced Option中啟用家目錄即可
      • repo init -u https://android.googlesource.com/platform/manifest
      • repo sync -j8
    • Reference: Downloading the Source

2017年7月15日 星期六

[Git] Portal


  • What is Git?
    • 分散式版本控制軟體
    • 利用 40 bytes的 hash key當作每次 commit ID
    • stages
    • 每次皆儲存完整內容, not diff
  • 名詞
    • hash
    • commit
    • repository (remote, local)
    • branch
    • HEAD
      • pointer to latest commit of current branch
    • Q: reference, rebase, cherry-pick?
    • parent -> 延伸至哪個 version
  • 行為
    • clone
    • checkout
    • commit
      • 修改 commit: 
        git commit --amend
    • push
    • pull
      • 從 remote 抓取各版 merge成新的 commit
    • fetch
      • 與 pull的差異是, 僅抓取 remote的 log, 不 merge
    • merge
      • fast forward (branch 合回 master, 且 master 未更改)
      • non-fast forward, merge into a new commit
      • rebase, branch的修改會串到 master 後面
        • Merge (From 連猴子都懂的 Git 入門指南)
          修改內容的歷史記錄會維持原狀,但是合併後的歷史紀錄會變得更複雜。
        • Rebase
          修改內容的歷史記錄會接在要合併的分支後面,合併後的歷史記錄會比較清楚簡單,但是,會比使用 merge 更容易發生衝突。
          • e.g. git checkout br3
          • git rebase master
          • 在 master 後面再串上 br3
    • stash
    • blame
      • 可以 line-by-line 秀出各 commiter
  • 教學
  • 設定
    • .gitignore
    • filemode
      • 常看到 git diff 只差在 old mode 100644 與 new mode 100755
      • 可以利用 git config core.filemode false 來隱藏這些錯誤
    • workspace config, user config, global config
  • 可搭配 Google 的 Tool repo 進階 checkout 多個 repository 對應的特定版號, 以 manifest做管理 (xml format), 或是 snapshot.xml 做管理

2014年11月25日 星期二

[Git] .gitignore

# Mac OS X
.DS_Store
profile

# XCode 
*.mode1
*.mode1v3
*.mode2v3
*.perspective
*.perspectivev3
*.pbxuser
xcuserdata/
project.xcworkspace/

# Generated files
*.o
*.pyc
build/
DerivedData
*.hmap
*.ipa
*.moved-aside
.idea/
Pods

# Backup files
*.swp
*~
*.lock
*.out

# version control

*.xccheckout