Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
230 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 Reply

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...