git tips
-
set ssh-keys and git won’t ask password in future.
- clone repository with ssh keys
git clone git@github.com:haijunsu/ServerTools.git - create develop branch on git hub
git checkout -b develop origin/master git push -u origin develop - create a branch to fix an issue
git checkout -b test_issue origin/develop - rebase current branch
git branch git rebase origin/develop - check git status
git status - add/discard file to track
git add <file>... git checkout <file> # discard changes - commit/discard changes
git commit -m "change comment here" git reset HEAD~ # discard commit - push change to branch
git push -u origin test_issue - review changes in a branch (test_issue)
git checkout develop git fetch origin git checkout test_issue && git pull --ff-only - merge change to develop
git checkout -b test_issue_merge develop git pull origin test_issue git fetch orign git checkout develop git pull git merge --no-ff test_issue_merge git push -u origin develop git branch -d test_issue_merge - merge change to master
git fetch origin git checkout develop git pull git merge master git push -u origin develop git checkout master git merge --no-ff develop git push -u origin master git checkout develop git merge master git push -u origin develop - Only add modified files and deleted files
git add -u - Only add untracked files
echo -e "a\n*\nq\n"|git add -i
Written on November 8, 2016