How to use git to track changes in another directory? -


i'm working on project have access code can't add version control source directory itself. (the main developer has own source control, it's not accessible/comprehensible/etc. reasons not relevant here.)

to keep sanity, track changes other developer makes, i'd have kind of version control system set up. (git version control system i've used since dark days of vss, that's i'll use.)

my current plan mirror existing codebase , initialize git locally. i'll need able compare local copy actual source when other developer makes changes.

my questions:

  1. is reasonable strategy?
  2. if so, should set git init --bare or git init?
  3. how should compare local copy actual source? diff -qnr source/ local-source/? git diff --no-index source/ local-source/? else?

first, bit of background.

in git, these concepts cleanly separated:

  • the git repository: contains git's data
  • the work tree: directory tree in filesystem work

when create local git repository git init /some/path, creates git repository @ /some/path/.git, , when run git commands inside /some/path , below, git finds repository, , assumes work tree @ /some/path.

now on situation:

i'm working on project have access code can't add version control source directory itself.

an interesting option can create git repository outside source directory itself, , set git_dir (the repo) , git_work_tree (the work tree) variables accordingly. example, if source directory @ /srv/project, this:

git init --bare /my/projects/repo.git export git_tree=/my/projects/repo.git export git_work_tree=/srv/project 

then can cd /srv/project , run git commands, if had regular git project in /srv/project (with git repository in /srv/project/.git). can use git commands usual, , repository operations done /my/projects/repo.git.

in real git repository use other repo remote, , use git operations make comparisons own branches.

i hope helps.


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -