Things to add to git ignore

xcuserdata
*.xcworkspace
Pods
.env
  1. Pods, there are pros and cons to removing it from git.
    • But for my case, it’s often too big to put be added to git.
    • If you already pushed some Pods files, remove files from git by “git rm -r Pods/”
  2. .env
    • env file is often for credentials like login key to download resource file(ex. Figma)

Can Interactive Rebase delete a pushed commit?

  1. Interactive Rebase is a rebase using “-I” option which enables to editing rewritten commits like squashing or editing messages.
  2. Rebase rewrites commits that are done after the specified commit. The author becomes the person who rebased. And also time and hash get changed.
  3. So if someone does rebase and rewrite commits which were pushed already.
  4. If others have merged the branch before the rebase, they already have original commits already
  5. And if they merge after the rebase, they have rewritten commits and original commits at the same time.
  6. When you view history in this case, there will be two different commits with same changes maybe with different authors and time. It makes hard to know who made the change.
  7. And if they merge their branch to develop branch, the confusing history will exist in remote develop branch too.
  8. That’s why you shouldn’t rebase pushed commits.

Reference:

  1. http://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-MessagesDeleting a commit
  2.  https://git-scm.com/book/ko/v2/Git-브랜치-Rebase-하기  “이미 공개 저장소에 Push 한 커밋을 Rebase 하지 마라” 

How to disable direct commit to develop branch allowing merges of pull requests [Github]

  1. Protected Branch
    1. Restrict who can push to matching branches
      1. This also disable merges of pull requests to other users
    2. Check Status requested
      1. This can make direct commit disabled, but also all pull requests
  2. Git hook
    1. in git directory
touch .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
#!/bin/sh

branch="$(git rev-parse --abbrev-ref HEAD)"

if [ "$branch" = "master" ]; then
 echo "You can't commit directly to master branch"
 exit 1
fi

if [ "$branch" = "develop" ]; then
 echo "You can't commit directly to develop branch"
 exit 1
fi