Difference between revisions of "Git"

From ElectroDragon
Jump to navigation Jump to search
(Config)
(Redirected page to Category:Git)
(Tag: New redirect)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
+
#redirect [[category: Git]]
== Basic Work flow ==
 
''' Init New'''
 
* Init new by git init, git add file and git commit
 
* Set a new repository on github
 
''' Add to Remote '''
 
* add local to remote service:
 
git remote add origin https://github.com/hechao/python
 
git remote add origin git@github.com:hechao/python.git
 
* This one is more easy and save user name and pass: '''git remote add origin https://{your name}:{you passwd}@github.com/{your name}/pmoney.git'''
 
# '''origin''' is the alias name for remote repository, here is pmoney.git, you can delete by '''git remote rm origin''', alias can be any name you like
 
# to check all alias like origin use:
 
git remote -v
 
''' Add, Commit and log '''
 
* git add .
 
* git commit
 
* git commit -m "Add test.rb to test git function"
 
''' Git push '''
 
* after added, then add files you worked, then you can push local to remove
 
git push -u origin master, or git pull origin master
 
#-u means remember the parameter, next time you can only use git push
 
# origin is the alias, and master means the branch
 
# git add and git commit should already be done before first push
 
 
 
''' Clone or fetch '''
 
* Update to latest git update: git fetch orgin, and need to mergin the orgin to local: git merge origin/master, or use git pull origin master to do it automatically
 
 
 
* git status to check if anything need to be committed
 
 
 
== Operation ==
 
=== File ===
 
* touch xxx.py
 
* git add .
 
* stage the difference: git diff --staged
 
* git rm *.py or git mv
 
or
 
 
 
=== For the last change ===
 
* git reset test.py // reset to unstage the file
 
* git checkout -- test.py // undo all the check on the file since from last commit
 
* to cancel the last commit, use git commit --amend
 
 
 
== Extra ==
 
''' Switch/create branch '''
 
* git branch new // create new branch
 
* git branch -d new // delete branch
 
* git checkout new // switch branch
 
== Git ==
 
* create a git on github
 
* in git gut "add remote", enter name and web address
 
* rescan, stage, commit and push
 
== Config  ==
 
* If use http:// or https git clone, only need set export
 
export http_proxy="http://192.168.8.101:1081"
 
export https_proxy="http://192.168.8.101:1081"
 
* Example http clone: git clone -b openwrt-18.06 https://github.com/openwrt/openwrt.git
 
=== Global Config ===
 
* git config --global user.name edragon
 
* git config --global user.email "you@example.com"
 
=== Proxy ===
 
* git config --global http.proxy http://127.0.0.1:1080
 
for ss socks5, use git config --global http.proxy socks5://127.0.0.1:1080
 
* git config --global https.proxy https://127.0.0.1:1080
 
for ss socks5, use git config --global https.proxy socks5://127.0.0.1:1080
 
* git config --global --unset http.proxy
 
* git config --global --unset https.proxy
 
* git config -l
 
* npm config delete proxy
 
 
 
== Common Issues ==
 
save username and pass
 
* set url: git remote set-url origin git@github.com:username/repo.git
 
* git config credential.helper store
 
== Other Useful tools ==
 
* torto https://tortoisegit.org/download/
 
 
 
== Reference ==
 
* https://try.github.io/
 
* www.git-scm.com
 
* https://www.vagrantup.com/
 
 
 
[[category:Topics]]
 

Latest revision as of 11:36, 2 May 2020

Redirect to: