Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
222 views
in Technique[技术] by (71.8m points)

Git checkout and scan subdirectories using python

How do I git checkout two branches and check for differences in subdirectories? Ideally, the scrip would do the following:

  1. Checkout two different copies of upstream.
  2. Scan both copies for different files and missing files.
  3. Include the users who modified the files last, the timestamp of the last change and users email.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your script could use the git worktree command in order, from one local cloned repository, to checkout two different branches in two separate folders.
(note: a Python library like gitpython does not support directly git worktree -- issue 719 -- but you can still call that git command)

For each file differences between the two branches, you can query through git log the last commit author/date of said file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...