0

I have a main repository with only a master branch and a personal repository with both a master branch and a dev branch. If I'm doing a pull from the personal/dev branch to the main/master branch, will git keep a record of each individual change that happened in the personal/dev branch (such that, say, temporary code which contained passwords can be found in main/master)? Or will it collapse the personal/dev changes into one merge change (such that temporary code which contained passowords cannot be found in main/master)?

Does the behavior depend upon the host software? FWIW, I'm using Stash.

Noel Yap
  • 18,822
  • 21
  • 92
  • 144

3 Answers3

1

Stash and GitHub have the same behavior in this case. The original set of individual commits is persisted and visible forever, even after you've merged the pull request and deleted all the remote feature branches. If you look in SourceTree at a project's branches and merges, it's very easy to see that all the fine-grained commits are still easy to check out, for anyone with access to git clone the repo.

Your secrets from earlier commits are not safe if you've pushed them to a remote git server such as Stash.

Joe Sondow
  • 76
  • 2
0

I assume you're talking about git merge ? The default way will keep all of the intermediate history of the alternate branch, however you can rewrite history of your dev branch before merging (i.e. git rebase -i or alternatively, you can perform a git merge --squash to create a new commit on master with the changes of the branch (no intermediate commits)

This SO Answer talks about the differences of these two options a bit: https://stackoverflow.com/a/2427520/504685


Edit to add: You could be talking about git pull, I'm just usually paranoid and often don't use it, but it seems that there is a --squash option that might be of interest to you as well there: https://www.kernel.org/pub/software/scm/git/docs/git-pull.html

Community
  • 1
  • 1
Charlie
  • 7,181
  • 1
  • 35
  • 49
  • I'm doing a pull through a pull request from a remote personal/dev to a remote main/master so I think I don't have control over options being used. – Noel Yap Jan 14 '14 at 16:52
  • 1
    Ah! Yes, if you do a pull request then all of the commits will come, so what you need to do is use `git rebase -i` locally, to make a clean branch, then push and do a pull request from the clean branch – Charlie Jan 14 '14 at 23:44
0

When you push master to Stash, the only commits that are given to the host are the ones that are reachable from master. If you've ever merged dev into master, this will include all of dev's commits from before the merge. This kind of behavior is part of the git repository model, and should be the same no matter what kind of host you're using.

This is easiest to see with a graphical diff viewer. With master checked out, type gitk at the command prompt. This will show all the commits that are reachable from master. If you do gitk --all, you can also see where the remote/master points, which tells you which commits are already in your Stash repo.

If you want to retroactively erase any private information, take a look at the removing sensitive information guide over at GitHub.

Ben Straub
  • 5,675
  • 3
  • 28
  • 43