git 如何查看合并历史记录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33802490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:32:08  来源:igfitidea点击:

How to see a merge history?

gitmerge

提问by nkint

I'm using git but I'm not an expert with it.

我正在使用 git,但我不是它的专家。

I inherited a legacy project and it follows git flow (and I like it): each new feature in a feature/namebranch. But when new features were merged into developmain branch they were not erased from origin. So that now in origin I see a lot of branches and I don't know which one are old one or which are working-progress.

我继承了一个遗留项目,它遵循 git flow(我喜欢它):feature/name分支中的每个新功能。但是当新功能合并到develop主分支时,它们不会从origin. 所以现在在原点我看到很多分支,我不知道哪些是旧的,哪些是工作中的。

Is there a way to have an history of the merges done between feature branches and the develop?

有没有办法在功能分支和开发之间完成合并的历史?

EDIT: I'm on a linux machine

编辑:我在一台 linux 机器上

回答by mkrufky

To get a history of merge commits made in the current branch, use the following command:

要获取在当前分支中进行的合并提交的历史记录,请使用以下命令:

git log --merges

回答by A...

can I offer another suggestion, that you search for the branches with head revisions that are included in the history of your develop branch ? It protects you from losing changes that were committed to a branch that had previously merged.

我可以提供另一个建议,即您搜索包含在您的开发分支历史记录中的头部修订的分支吗?它可以保护您不会丢失提交给先前合并的分支的更改。

Something along these lines :

沿着这些路线的东西:

git log --oneline develop > /path/develop.log

# Just in case anyone's broken process and committed a bugfix directly to a release branch
git branch -a | grep 'remotes\/origin\/release\/' | while read branch; 
do 
    git log --oneline $branch > /path/"$branch".log; 
done

git branch -r | while read branch;
do
    git log -1 --oneline $branch | awk '{print }' | while read commitID;
    do 
        if grep -rq $commitID "/path/" ;
        then 
            echo "git push --delete origin \"$branch\"    Deletable   $commitID";
            break;
        #else 
            # the head revision hasn't been committed to any 'master' branch
            # echo "$branch $commitID"; 
        fi; 
    done; 
done

回答by Dharani Dharan

install this

安装这个

sudo apt-get install git-gui

and run gui command to execute

并运行 gui 命令来执行

git gui