How can I prevent foxtrot merges in my ‘master’ branch?

The following pre-receive hook will block those: #/bin/bash # Copyright (c) 2016 G. Sylvie Davies. http://bit-booster.com/ # Copyright (c) 2016 torek. http://stackoverflow.com/users/1256452/torek # License: MIT license. https://opensource.org/licenses/MIT while read oldrev newrev refname do if [ “$refname” = “refs/heads/master” ]; then MATCH=`git log –first-parent –pretty=’%H %P’ $oldrev..$newrev | grep $oldrev | awk ‘{ print \$2 }’` …

Read more

Git conflict (rename/rename)

Given the following test-setup: git init resolving-rename-conflicts cd resolving-rename-conflicts echo “this file we will rename” > will-be-renamed.txt git add -A git commit -m “initial commit” git checkout -b branch1 git rename will-be-renamed.txt new-name-1.txt git commit -a -m “renamed a file on branch1” git checkout -b branch2 master git rename will-be-renamed.txt new-name-2.txt git commit -a -m …

Read more

git workflow: Can I prevent a certain file from being merged to another branch but still keep it under version control?

I found an answer on another question on Stack Overflow, credit goes to fcurella: Let’s say you want to exclude the file config.php On branch A: Create a file named .gitattributes in the same dir, with this line: config.php merge=ours. This tells git what strategy to use when merging the file. In this case it …

Read more

Pull in changes from a Github fork

Pulling in a single commit would be a cherry-pick and would rewrite the commit ID (and mark you as the committer while retaining the author). The process is pretty straightforward, though: git fetch git://github.com/user/project.git git cherry-pick <SHA-COMMIT-ID> You get the SHA from the repository log, for example: git log –oneline b019cc0 Check whether we have …

Read more

Unmerge a git branch, keeping post-merge commits

Read through Pro Git – Undoing Merges. Basically, you git revert the merge commit: git revert -m 1 hash_of_merge_commit You may end up with some conflicts that you’ll have to manually unmerge, just like when merging normally. Additional links: Git SCM – Undoing Merges Git Ready – Rolling back changes with revert