mhafizhasan
9/25/2017 - 7:39 AM

Git Basic

checkout local branch to be merged with master
git checkout <branch-name>

merge remote master with local branch
git rebase master <branch-name>

if any conflict, fix them and add
git add <fixed-conflict-files>

continue with rebase
git rebase --continue

git config --global user.name - check current username for commit
git config --global user.email - check current email for commit
git config --global user.email "hello@mhafizhasan" - update email for commit

use of git alias command saved to ~/.gitconfig

git config --global alias.hidden '!git ls-files -v | grep "^[a-z]"'
[alias]
  hide = update-index --assume-unchanged
  unhide = update-index --no-assume-unchanged
  unhide-all = update-index --really-refresh
  hidden = !git ls-files -v | grep \"^[a-z]\"
  ignored = !git status -s --ignored | grep \"^!!\"

start ignore file
git update-index --assume-unchanged <file>

start keep track again
git update-index --no-assume-unchanged <file>

show all ignored files
git ls-files -v | grep "^[a-z]"

remove from cache for ignore file
git rm -r --cached <file>

remove local branch

git branch -d <branch_name>

remove remote branch

git push origin :<remote_branch>  

or 

git push origin --delete <remote_branch>

synchronize branch with remote

git fetch -p

checkout remote branch

git fetch
git checkout <remote_branch>

rebase branch with master

git fetch origin          # updates origin/master  
git rebase origin/master  # rebases current branch onto origin/master  

push master as remote new branch

git push origin master:<new-remote-branch>
git remote set-url origin <new_url_here>
1. Pastikan berada di branch Master
git checkout master
2. Dapatkan latest update dari Master
git pull origin
3. Checkout ke branch baru berdasarkan ISSUE code
git checkout -b MP4
4. Buat kerja dalam branch tersebut
5. Bila nak commit:
git add <filename> atau git add . (add semua file)
git commit -m "description commit tersebut"
6. Kalau rasa dah siap dan hantar:
git status (pastikan clean)
git push origin <namebranch>
copy paste merge request link dan paste ke browser
create Merge Request

git stash save "my stash" save stash

git stash list show stash list

git stash pop unstash

git stash pop "stash@{1}" unstash spesific stash

git stash drop distroy stash

git checkout origin/master <path_to_file>