Merge GIT branch without commit log

后端 未结 3 1594
栀梦
栀梦 2020-12-23 09:48

Currently when I\'m using GIT I create a branch for each job and make various commits before I\'m finished. I then merge back with my master branch and push upstream. I\'m l

3条回答
  •  被撕碎了的回忆
    2020-12-23 10:09

    there is, but it is nonsense. why do you want to do that? you'll lose all branch history and information.

    you could use g's commit message for your merge commit and then browse history with the --first-parent option.

    if you really want to lose history from your branch use git merge --squash, i do not recommend it though

    edit

    in case you are not happy because you do not consider your history very clean, you can use git's rebase feature:

    you can retroactively edit old and create new commits from your existing branch (in effect rewriting it). it allows you to reword commit messages, split commits, squash commits into a single commit, re-order commits, etc.

    you should only use rebasing when you haven't published your branch (i.e. it is only a private branch), because it will give other developers headache and could cause merge problems later on, if someone kept working on the old (before rebased) branch.

提交回复
热议问题