Summary of Git Command
Get all sources from remote git
- create workspace or project folder.
- use the "git init"command in the Project folder.
- git remote add origin https://....../xxx.git
- git pull origin master
When committing to a remote location
- how to set global config in git
- git config --global user.name "steve.lee"- git config --global user.email "steve.lee@example.com" - git add [filename/ . ]
- git commit -m "message"
- push -u origin master
Summary of frequently used commands in Git
- git init = create a git
- git clone git_path = acquiring code from somewhere
- git checkout branch_name = select a branch
- git checkout -t remote_path/branch_name = select a remote branch
- git branch branch_name = create a branch
- git branch -r = list of a remote branch
- git branch -a = list of a local branch
- git branch -m branch_name change_branch_name = change a branch name
- git branch -d branch_name = delete branch
- git push remote_name --delete branch_name = delete remote branch
example: (git push origin --delete gh-pages) - git add file_path = select code that edited
example: (git add *) - git commit -m "commit_description" = fill out description on code that selected
example: (git commit -m "comment~~") - git push remote_name branch_name = send the code that added and committed to git server
example: (git push origin master) - git pull = pull the newest code from git server and merge on the workspace that you are staying
- git fetch = fetch the newest code from git server
- git reset --hard HEAD^ = cancel previous code that committed
- git reset --soft HEAD^ = maintain code and cancel only commit
- git reset --merge = cancel the merge
- git reset --hard HEAD && git pull = force all of git code to somewhere
- git config --global user.name "user_name" = change name of git account
- git config -- global user.email "user_email" = change mail of git account
- git stash / git stash save "description" = change branch after save code temporarily
- git stash pop = fetch / pull code saved temporarily
- git branch --set-upstream-to=remote_path/branch_name --> solve error about git pull no tracking info
Comments
Post a Comment