# Git GitHub Gitserver --- ### What is Git Git is Version Control System(VCS),it is use to manage program and code and it can protect all of the program file modify record and history version ---- ### install and use git [Git Website Click me](http://git-scm.com/) Git has GUI , but i don,t recommend you to use that Let,s try to use Git bash ---- ### Create a Folder ```code=ubuntu mkdir gittrain cd gittrain ls gittrain ``` --- ### Git init ```code=ubuntu git init ``` ---- ### Create a txt file ##### And give it some sentence ```code=ubuntu cat > poem.txt nano poem.txt ``` ---- ### Add to repository and Check git status ```code=ubuntu git add poem.txt git status ``` ![](https://i.imgur.com/UcHzHYC.png) this message told us we have file(poem.txt) want send to repository storage ---- ### Commit it!! ```code=ubuntu git commit -m 'this modify explaination' --author='modifier <modifier,s email>' ``` ![](https://i.imgur.com/0cDccAh.png) --- ### oops my profile !!! i entered wrong ##### Don,t worry we have this ```code=ubuntu git commit -amend -m 'this modify explaination' --author='modifier <modifier,s email>' ``` ---- ### try to amend txt file ![](https://i.imgur.com/wO0QthF.png) and now we amended the file we should add to repository right? ---- ### add and commit ```code=ubuntu git add poem.txt git commit -m 'this modify explaination' --author='modifier <modifier,s email>' ``` ##### check our repository what file are there git graphic master is meaning main branch ```code= linux gitk ``` --- ![](https://i.imgur.com/zaqwdha.png) --- ### Two view mode patch and tree tree mode: full display node content patch mode: full display of differences with last node > When we finish checking ```code=linux exit ``` --- ### Sum up Git porgression ![](https://i.imgur.com/q2JZvup.png) --- # Git setting file ---- ### 1.config (.git) 1. have final decision right ,even if set the file ---- ### 2. .gitconfig (home directory) 1. when last file setting file didn,t setting , it take effect and it only acting on the login user ---- ### 3. mingw64/etc/gitconfig 1. when 1 , 2 didn,t setting ,it is public file,it can take effect all of the user --- ### git config command ```code=git git config-l ``` it will display file of the above it setting item and asending display ---- ### how to choose the file what i want to see ![](https://i.imgur.com/W63jncE.png) ---- ##### mingw64/etc/gitconfig ```code=git git config --system -l ``` ##### home directory/gitconfig ```code=git git config --global -l ``` ##### .git/gitconfig ```code=git git config ``` ---- ```code=git git config -l ``` ![](https://i.imgur.com/xPOD8gV.png) --- ### amend it did you remember git commit ```code=git git commit -m 'reocord' --author 'name <email>' ``` ---- ### use config to amend it .git/.gitconfig ```code=git git config user.name 'new name' git config user.email 'new email' ``` home directory/.gitconfig ```code=git git config --global user.name 'new name' git config --global user.email 'new email' ``` mingw64/etc/gitconfig ```code=git git config --system user.name "new name" git config --system user.email 'new email' ``` ---- ##### but i want to remove it!!! ```code=git git config --unset user.name git config --unset user.email ``` and also you unset .git home directory system br --global --system ---- ### supplement ```code=git git commit -m 'explaination' ``` as same as ```code=git git commit --message='explaination' ``` --- ### command is too long it is trouble for me ---- ### a personal setting 『Alias』 ##### to shorter our usually use ```code=git git config alias.yourcommandalias 'original command' ``` yourcommandalias can not involve space ---- ##### also can give it --system --global --unset --- ### text editor if we use git commit -m 'record' but it record lots of thing you can use text editor git default set 『vi』 is there editor ---- ### but... == ![](https://i.imgur.com/x1ZNIpg.png) is hard to edit(i think) ---- ### How about use nano ```code =git git config --global core.editor nano ``` all right we set nano is our default editor ---- ### and now edit message is easier ![](https://i.imgur.com/WE7Wefj.png) --- # Git diff ---- ### diff can compare file where has edit ##### assume our repository has poem.txt(last we added) and now we edit poem.txt we execute it to compare it ```code=git git diff ``` ---- ![](https://i.imgur.com/bl5Y8SW.png) a/filename is our folder file b/filename is repository file @@ -1,3 +1,3 @@ -1,3 is meaning a file row 1 col 3 +1,3 is meaning b file row 1 col 3 <p color="red">(-) is our lost</p> <p color="green">(-) is our added</p> ---- ##### but i think gitk is more convient than git diff beacuse sometime chinese word cannot present on bash but gitk doesn,t ---- ### so git offer anthor command ##### git difftool ---- ![](https://i.imgur.com/nQc49jW.png) that what say compare ---- ### also it set on your config(assume i want to use kdiff3) ```code=git git config --global diff.tool kdiff3 git config --global diff.tool.kdiff3.cmd "'D"/Program Files/Kdiff.kdiff3.exe'\"\$LOCAL\"\"\$REMOTE\"" git config --global difftool.prompt false ``` --- # add to repository ---- ##### some file i don,t want to added to repository we have following 3 type 1. tracked 2. ignored 3. untracked ---- ##### initial all of the file is [untracked] when we execute ```code=git git status ``` it will list untracked file mean which files we didn,t classify ---- ### Normally all file in folder should been classify [tracked] and [ignored] ##### tracked <- has been added to git repository ##### ignored <- git won,t check this file ---- ### Want [tracked] -> [ignored]??? should add a file named .gitignore in folder ---- ### try it now add poem.txt in folder and give it some sentence ![](https://i.imgur.com/FIOA7xl.png) and create new folder in folder name folder new folder should invlove poem3.txt and give it some sentence ![](https://i.imgur.com/IurFwSQ.png) ---- ### no add to repository right? ![](https://i.imgur.com/UpP0Hog.png) ---- ### now we add poem.txt add to repository ```code =git git add poem.txt git commit -m '1st commit' ``` ---- ### create .gitignore ```code=linux touch .gitignore ``` ---- ### edit .gitignore by wordeditor ```code=linux nano .gitignore ``` and type in ![](https://i.imgur.com/1XgPe2K.png) ---- ### check it out !!! git status ![](https://i.imgur.com/2NZ2J4O.png) folder is disappear right!!! and only poem2.txt is untracked ---- ### now moddify our txt file poem.txt poem2.txt folder/poem3.txt add some sentence ![](https://i.imgur.com/NcJlr3Y.png) ##### check it ```code=git git status ``` ---- ![](https://i.imgur.com/FNjx1Sj.png) because poem.txt is tracked so it will been check it was been modified !!!gitk or git diff check it!!! but folder/poem3.txt was ignored so git didn,t check it ---- ### .gitignore comment in file we can add some comment use start in # and filename can use * filepath use / for example i ignore all of endwith.txt file ! is meaning opsite ```code=nano *.txt #設定不要忽略note.txt !note.txt ``` --- # control commit ---- we have know use git add to add to index and if we didn,t excute git add then will not effect ,then git commit repository ---- #### sometimes we repent to git add ex: add wrong file Situation 1: git only execute git init Situation 2: has execute git commte before ---- #### Situation 1 ```code=git git rm --cached filename ``` remove git index filename ---- #### Situation 2 ```code=git git reset HEAD filename ``` ---- ### git rm ---- ##### git will check at first 1. git index didn,t have file(mean didn,t excute git add before),on the contray git rm will not effect and infrom you 2. folder file content as same as repository ,on the contray git will infrom you and not effect avoid to lost data **after check** git will remove folder file and it will record on index repoistory must remove that file and now excute git status will told you deleted finally execute git commit to remove that file ---- #### git rm --cached filename tell git no need to update this file to repository status(tracked -> untracked) and remove this file in index(only index) --- ### observe commit node we have know gitk can show git workflow ![](https://i.imgur.com/Z9jTnq2.png) **SHA1 ID** ---- #### SHA1 ID present that node ID ###### supplyment git log as same function as gitk but it didn,t have graph but...try it ```code=git git log git log --graph git log --graph --oneline ``` ---- git not only offer sha1 id but also offer HEAD ### HEAD is mean newest commit node ```code=git git show HEAD ``` due to commit node is suquential then we can find older commit node like this ---- ```code=git commitnode_SHAID^number commitnode_SHAID~number ``` **^ is mean father commit node** **~ is mean which layer** for example HEAD~2(HEAD second layer father commit node) ---- ##### supplyment git commit ID is combined with long HEXnum when you specify commit ID you don,t need to enter full number ,you just only type the first four number git will automatically find corespond commit node if cannot execute try enter more num ** HEAD alias @ ** ->HEAD~1 == @~1 ->HEAD^2 == @^2 git show [filename] show that file newest version moddify condition git show commit commit_node:filneame show specify node file content --- ### git tag we can add some customize tag at commit_node ---- ##### like this ```code=git git tag customize_tagname commit_node_IDortag ``` ---- ##### now we can we customize tag in command ```code=git git tag -d commit customize_tagnem ``` ---- ### so why git reset cannot use in condition 1 because HEAD is empty (hasn,t commit it) ---- ##### supplyment repository recovery to assign commit_node ```code=git git reset option commit_node_IDortag ``` option: * --soft only modify repository * --mixed(default option) modify repository and index * --hard all of will modify invlove(repository index folder) --- ### Compare file difference and git restore from repositort to folder ---- ![](https://i.imgur.com/EreehnK.png) assume poem.txt have 4 version the oldest 2 version have commit to repository third version in index(git add) newest in folder ---- ##### --no-index To compare folder file1 and file2 ---- ### git repository to folder ```code=git git checkout commit nodeIDortag [file1 file2 ...] ``` ###### supplyment git checkout can use when file have branch ---- ### auto record when folder file is different with repository(checkout file) then checkout file will auto record in index ===================================== so if we type git commit let it become newest version to avoid this problem we can execute ```code=bash git reset HEAD //after execute git checkout ``` ---- git checkout default set file is second newest file also you can ignore IDorTag ```code=git git checkout file1 file2 ``` sequence index->newest commit->second newest .... if want to checkout repository all file newest version ```code=git git checkout . ``` ---- ### git grep to find meet condition filename ```code=git git grep "condition" commit_node ``` git will find commit_node all the file and show all meet the condition filename ---- if didn,t specify commit_node will find folder file condition(Uppercase an lowercase is distinct) but we can add 『-i』 to ignore that condition involve which you specify string can add『-l』 condition want to know file involve how many line string can add『-c』 ---- find file in multicondition find filename which involve two words can add『-e』 ```code=git git grep -e 'word1' -e 'word2' commit_node ``` also can add OR ANS ```code=git git grep -e 'word1' --and\(-e 'word2' -e 'word3'\) commit_node ``` ---- ### git blame know the file lastest editor ```code=git git blame filename ``` if filename too long can add 『-L』 to choose start in which line and end in which line for example ```code=git git blame -L start_line , end_line filename git blame -L start_line , filename git blame -L end_line filename ``` ---- ### git mv amend filename or foldername ---- #### original method 1. use CMD rename file or folder 2. use Git Bash [git add -A newfilename] to add rename file to index , and remove fileoldname in index 3. execute git status Git will auto detect new file and old file, and add it to repository to avoid repeat storage same file 4. execute git commit to adding to the repository ---- #### new method ```code=git git mv old_filename new_filename //add to index git commit ``` WOW that is really easier than old one ---- ### Temporary storage folder condition this function can temporart storage our folder [file amend condition] ---- for example when our peoject has,t finish , but we should repair another porject now at that time you should stop your project you can use temporary storage ```code=git git stash save ``` ---- it will do 1. stroage tracked file and newest file version in repository 2. folder trackd file backup to repository newest file version and now we execute ```code=git git stash list //srah@{0}:WIP on (no branch):01325b4 3rd commit ``` it will present basic file version WIP(work in progress) 01325b4 3rd ->commit_node and explaination<- the newest version --- ##### now we can start our another project when we end our another project and need to recovery our old peoject to git stash save condition 1. backup our project from repository(git stash save version)as samas git stash list commit version,we can use git checkout commit ID . to complete it 2. execute git stash pop ot git stash apply to take out out temporary file and merge to current folder when complete temporary file will be cleaned and execute git stash list will not appear any message, if have any problem in this run it will keep file avoid lost the file ---- ### clean git repository we are very offen use repository those datas really messy and some data is useless ,it will waste out storage and effienecy,now we should clean up our repository, acctually git can clean itself automatically like git rebase. but it change too much in repository let data become messy,now we clean by ourself ---- ### git gc(garbage collection) addition feature 1. --agressive - default type is the most fast function to check repository and clean it,add --agressive git will more careful to check and clean it(i suggest you seldom use this function too offen clean is useless) 2. --auto - git will detect does repository need to clean,if repository condition well it won,t be cleaned 3. --no-prune - this option is ask git don,t [clean] repository unuseful data only [sort out] them --- # git project management ---- use git to manage your own project ![](https://i.imgur.com/qFEnbSm.png) ---- ##### Warning don,t delete .git folder .git store data ```code=git git init git status git add . git commit -m "initail app project" gitk //gitk& can execute in wallpaper mode git checkout HEAD //git repository -> folder ``` --- ### get git repository statistic data and draw statistic graph statistic data involve join developer table , commit account number , code line ,in addition we can statistic routine time ---- ### git log this command will from the lastest commit_node list forward every commitment in chronological order,it involve ID executer datetime time and explaination. in fact if you just want to observe commit_node data,[gitk] will more convience ,but the advantages of [git log] is it can combine with option to filt the specify commit like[--author] can find the executer ---- ```code=git git log --author='A' //find author name start withA ``` if you want to observe some file have been modify commitment ```code=git git log file1 file2 ``` ---- ##### present time and datetime of course it can add option like [--after (--since)] or [--before(--until)] to present during commitment ```code=git git log --after="2017-08-18 9:30" --before="2017-08-18 21:50" ``` ---- ##### present edit condition add [--stat],[--numstat],[--shortstat] can show every commit_node edit condition ![](https://i.imgur.com/IWZaTEM.png) ---- it will present how many file has been modify , added how many line , deleted line if add [--oneline] will more clear to show it ![](https://i.imgur.com/WNOzFla.png) ---- ##### show total add/delete code line can combine with other program tool (pipe function) EX: ```code=git git log --pretty=tformat: numstat | gawk '{ add += $1 ; subs += $2 ; loc += $1-$2} END{printf "add lines: %s removed lines : %s total lines: %s\n",add,subs,loc}' ``` ---- ##### supplyment when git command too long when git command length over monitor height,signment will automatically stop,we can enter following key to continue 1. key[j] to show next line 2. key[space] to show next page 3. key[h] to show operation explaintion 4. key[q] to end up ---- ### git shortlog this command will ordered by alphabet list (n) n=commit count ---- ![](https://i.imgur.com/jvDrmUb.png) also we can add[--numbered(-n)]option it will ignore commitment add[--summary(-s)] to show editor modify condition ![](https://i.imgur.com/JCYNzuD.png) ---- ### git ls-files to list git repository file list and we can conbine with **xargs wc** this two tools to count file line ```code=git git ls-files | xargs wc -l ``` ![](https://i.imgur.com/P4YX4oQ.png) the foremost number is file line ---- ##### only show file line ```code=git git ls-files | xargs cat | wc -l ``` ---- # gitstats draw statistic graphfic Gitstats is an opensource code project(use python develop), use git command to get data from repository and draw graphic by gnuplot plugin(require [python](https:/python.org/) [gnuplot](https://www.gnuplot.info) [GitStats](https://github.com/hoxu/gitstats)) but it only support python2 ---- in gitstats folder ```code=python python gitstats.py "repository route" "webpage route" ``` it will present git statisic information in webpage(index.html) --- ### project branch when we are developing project ,we may need branch after modify complete we merge them together or make two project ---- ### master when execute git init git will produce master branch automatically ![](https://i.imgur.com/cm0ihIT.png) inside the parenthese is our project branch at that time ---- ### create new branch ```code= git branch branch_name commit_nodeIDortag ``` 1. if we were specify commit_node ID or Tag at last,new branch we create at that commit_node,on the contray create at newest commit_node 2. we only type git branch without any parameter, git will list all of the repository branch ---- ### operate branch after we create branch we can execute this command to switch currently operate branch ```code= git checkout branch_name ``` ---- ### try it now we create a new folder and create a txt file poem.txt in that folder give it some sentence ---- ##### git bash cd to this folder and execute following code ```code= git init git add . git commit -m "Add poem1.txt" git branch lee-by //but now we are operate master ``` ---- ##### supplyment 1. if we want to switch to new branch after create newbranch ,can execute git checkout -b newbranch_name commit_node_idortag ,and execute git checkout newbranch_name 2. also we can create branch on branch,EX:after create lee-bt branch ,execute git branch lee-by2 leeby , it will create lee-by2 branch 3. branch name must can be explain branch purpose,EX:for test and debug branch, branch name can use **bug** at the beggining of file name,at debug branch create new branch can named feat/multi-selection 4. present some specify branch name,can use command git branch --list expresion ```code= git branch --list bug/* git will list all of branch which filename is begging of file bug/ ``` ---- ### create new file poem2.txt in folder and give some sentence ```code= git add . git commit -m "Add poem2.txt" ``` ---- ### create poem3.txt but checkout at first after that we add and commit ```code= git checkout lee-by git add . commit -m "add poem3.txt" ``` ---- #### Git graph ![](https://i.imgur.com/ChKAf9A.png) ---- ### think about this why poem2.txt isn,t include in lee-by branch??? we didn,t remove it but it is disappear in lee-by branch ---- beacuse when switch branch , git will compare current branch and switch branch whether their tracked as same(only check filename didn,t check content). if the file only tracked by current branch but didn,t tracked by switch branch, that file will be removed. but how to get the removed file **back to the repository** ```code= git checkout master git checkout lee-by ``` ![](https://i.imgur.com/5gba6UI.png) ---- 1. when we switch branch git will check repository the current branch and switch branch whether their file are same, if not git need to det the file from repository for branch meet the branch file, but avoid indromation missing when git cover the folder data , git will check that file has or not add to the repository ,if it isn,t git will warning you and shut to execute to avoid data missing, if we don,t want to store these any more but it hasn,t add to repository can do that ```code= git checkout -f branch_name ``` 2. except the trackd file, both untracked and ignored files git won,t do any produce ---- ##### supplyment Alought when git switching branch , git will try its best let folder file recover to original condition in branch,but not sure their content as same if we modify our current branch file but didn,t commit , when we are switdch branch will have some error so remeber to commit and look git status or git checkout . ---- ### gitk --all check it(or git log --graph --oneline --all --decorate) ![](https://i.imgur.com/39Vdytu.png) - --oneline(use most simply way to present) - --graph(draw commit_node evolution) - --all(present all branch) - --decorate(present branch name) ---- ### remove commit_node ```code= git branch -d branch_node ``` ---- # merge commit we cannot remove branch which hasn,t merge to the other branch ---- ##### remove hasn,t merge branch ```code=git git branch -D branch_name ``` rename branch ```code=git git branch -m newname ``` --- ### deal with Detached HEAD problem ---- assume have build a git repository and added some commit_node now we execute this command ```code=git git checkout ^HEAD ``` ![](https://i.imgur.com/bbjvLol.png) ---- ![](https://i.imgur.com/0kBOei2.png) now HEAD is head to the lastest two commit_node and attention **the inside of the parenthese isn,t the current branch is commit_node ID** to present operate object isn,t any other branch now ---- ##### supplyment git checkout commit_node git checkout commit_node . is different both command will let folder file become that node data in addition the first command will let HEAD head for that commit_node form detached HEAD condition but the second command doesn,t ---- ```code=git git checkout HEAD^ ``` ![](https://i.imgur.com/6pB7Xwq.png) ---- assume we modify folder file and use git add and commit command repository will become ... ---- ![](https://i.imgur.com/NlDKxYA.png) ---- this branch will haven,t name can execute choose one ```code=bash gitk --all git log --graph --oneline --all --decorate ``` ---- and look status ```code=git git status ``` present ```txt HEAD detached from <commitID> ``` ---- ### how to deal with that method 1: give up that branch and delete it method 2: merge branch and switch to another branch ```code=bash git branch this_noname_branch //<-give it a name git checkout master git branch -D noname_branch ``` the noname branch will remove from the repository and repository will backup to original status --- ### Merge project branch and deal conflict ---- in most cases , project branch will merge to master branch,except we dicide to individual it, command like ```code=git git merge branch_name ``` ---- this command will merge specify branch to git working branch assume we merge brnach A and B we execute following command ```code=bash git checkout A git merge B ``` let B merge to A ---- ```code=bash git checkout B git merge A ``` A will merge to B ---- ![](https://i.imgur.com/SPGBD0y.png) and we can delete old branch ```code=bash git branch -D A/B ``` ---- ##### supplyment if we repent to merge branch,we can execute [git reset] to recover to before merge condition ```code=bash git reset --hard HEAD^ ``` - --hard(meaning both folder and repository should recover) after merge HEAD_node will have two parent_node we choose by command [HEAD^1] and [HEAD^2] or use commit_node ID to specify ---- althought merge concept is easy, but in pratical we should take some condition in consider For example : the easiest condition after we create a new branch(name:bug/123) we commit and edit it, master banch didn,t do any change like ---- ![](https://i.imgur.com/MVeTNfz.png) ---- bug/123 is branch from master but have edit bug/123 at now we merge bug/123 and master we should ckeckout to master branch and execute git merge bug/123 ```code= bash git checkout master git merge bug/123 ``` ---- ![](https://i.imgur.com/IM0W4BX.png) ---- ##### fast forward merge advantage: won,t create new commit_node master branch only [fast forward] to bug/123 HEAD therfore it wont leave merge record ,but if want to leave recoed can use this command ```code= bash git merge --no-ff branch_name ``` - --no-ff (meaning don,t use fast forward merge) it will create commit_node ---- ![](https://i.imgur.com/feJQTZ2.png) ----- ##### 3-way merge ---- fastforward merge only modify one branch but 3-way merge is both branch have edit ![](https://i.imgur.com/2BpfuSC.png) ---- if we merge this two branch when two branch edit same file will conflict. now we should deal with that by ourself ---- ![](https://i.imgur.com/VoI30qG.png) ---- let git doesn,t know which file should be the master branch ----- ##### supplyment when we are merging have some conflice we execute that command to give up this merge ```code=bash git merge --abort ``` ---- we can use [git diff ] to check it and edit file content and we delete draft branch create new commit_node ---- ### merge tool deal confilt ---- Setting Merge Tool ```code=bash git config --global merge.tool kdiff3 git config --global mergetool.kdiff3.cmd\"'D"/Program Files/KDiff3/kdiff3.exe'\"\$BASE\"\"\$LOCAL\"\"$REMOTE\" -o \"$MERGED"" git config --global mergetool.promt false git config --global mergetool.kdiff3.trustExitCode true git config --global mergetool.keepBackup fasle ``` ---- Now we can reset git repository backup to unmerge condition ```code=bash git reset --hard HEAD^ // merge draft git checkout master git merge draft ``` ---- when we have conflict ```code=bash git mergetoll ``` after we finish confilct we can create commir_node and send it to repository ---- # Cherry-Pick as same as merge [Cherry-Pick] command not focus on branch,but commit_node .in other word , we merge someone commit_node to folder file ```code=git git cherry-pick commit_nodeIDorTag ``` ---- default condition this command will create new commit_node,if we don,t want to create new commit_node you should add [-n] this option,in addition we should notice when exexcute it before,our folder file should commit to the repoistory or Cherry-Pick will have some conflict ---- ##### when conflict we have two opinion option 1: give up execute backup to original condition option 2: execute ```code=git git cherry-pick --abort ``` let folder and repository backup to original condition and edit folder file to the correct condition and ```code=git git add . git cherry-pick --continue ``` ---- otherwise we can use other tool like MergeTool to edit conflict file . we only should execute it after git present warning message ```code=git git mergetool ``` finish all the conflict execute ```code=git git cherry-pick --continue ``` Yah finish --- ### process Detached HEAD condition and backup to old commit_node we have discuss detached HEAD promblem we have switch to another branch cause HEAD tag stop at old branch will cause git not on ant branach at now we execute commit will create a noname vranch ---- Did you remeber how to merge noname branch ```code=git git branch noname_branch git checkout master git merge noname_branch ``` ##### 3-way merge ---- we have leared [git reset] this command , it can backup repository to old commit_node condition if we add [--hard] this option folder file will backup together, in addition we have a function like revert command ,it also can backup folder file to old commit_node , in different , revert command wont delte git repository commit_node ,in contray , it will create a new commit_node ---- FOR example the following command will reset to [HEAD^] this commit_node condition ,and repository will create a new commit_node ```code=git git revert HEAD ``` ---- ##### notification - git revert commit_node - backup to brfore specify commit_node node folder file - git reset --hard commit_node - backup to specify commit_node folder file ---- ##### supplyment execute [git revert] will create commit_node so it will open word editor automatically(git default set vi) leave vi should type : at first and type q and enter it to leave it ---- when we are execute [git revert] also we may have some conflict we can regret it ```code =git git revert --abort ``` infact git revert is like git checkout commit node1 node2 their function also backup the folder file to old commit_node but [git checkout] won,t lead to conflict condition --- ### Rebase command to update branch begin_node we have learned how to create a new branch,wait branch finish develop and pass the test , merge it to master branch,this function let us edit and test whatever i want, no need to worry about master branch,now we should take in consider a condition ---- after we create project, we will spend lots of time to finish it, in other side master branch need update continuely , in this condition, in order to Synchronize master and other branch in other word maintain branch consistency ,we must edit master branch timing and apply to developing branch.this merge method is different to we have introduce method. - we have introduced method - after develop merge to master branch - now - master branch edit merge to developing branch ---- ```code = git git checkout draft git merge master ``` ![](https://i.imgur.com/dmdWUHP.png) ---- after merge master and drfat branch will update continuly, after a while we should merge master to draft branch, if this condition continue will cause graph complex ,even if git repository will not have bug and folder project look like everything is ok . ---- To simply our git graph we can use [rebase] ##### rebase ![](https://i.imgur.com/mj1JFax.png) --- ### rebase command this command like merge now let master branch merge to draft branch ```code=git git ckeckout draft git merge master ``` rebase meoth ```code=git git checkout draft git rebase master ``` ---- rebase command also like merge may have some conflict rebase give up and back up to original condition ```code=git git rebase --abort ``` edit file and continue ```code=git git add . git rebase --continue ``` ---- ##### supplyment MergeTool can also process rebase conflict it should set up and execute git mergetool when have conflict finaly git rebase --continue ---- althought rebase command is easier commit_node evolutiob,but it will modify old commit_node if this project is corperate with other people may be it is not suitable use rebase or cause git repository not consistency , we recommend use merge command ---- ### how to deal with after rebase we regret stop rebase ```code=git git rebase --abort git reset commit_node //reset to commit_node ``` ---- but how to find old HEAD data ```code=git git reflog HEAD or branch_name(default HEAD) ``` it can find HEAD or any branch mof=dify condition ---- ![](https://i.imgur.com/fOSc26I.png) find master branch ```code=git git reflog master ``` ---- now we know the commit_node we can reset node to which we specify ```code=git git reset --hard HEAD@{3} ``` --- # project branch merge pratical training ---- ### import git strategy to project we will separate develop features in each branch wait for everybranch finish developing we are able to send to user and develop new version ---- ![](https://i.imgur.com/rtalqp2.png) ---- this graph seem like correct but actually is not ideal git graph must be like master branch is store after develop version,another branch is store add/repair feature branch ---- ![](https://i.imgur.com/Oj3wnnw.png) isn,t is more clearify ---- ### git combine with project pratical training ---- project can divide in three part 1. begin step 2. develop step 3. finish step ---- ##### begin step 1. create a new project 2. initailize this new project and git repository 3. edit .gitignore file(if it is not in folder we should create a new one) 4. create project develop branch ```code=git git checkout -b develop //create develop branch and switch to it ``` can use gitk to look graph ![](https://i.imgur.com/V8bJjjN.png) ---- ##### develop step 1. To switch your code develop tool and develop your project 2. add/edit/delete resource file 3. back to the git ```code=git git add -A git status // i suggest your execute this after every git add git commit -m "explaination" ``` ---- ###### supplyment git add 1. git add . - new file and edited file add to git index but the deleted file will not record in index as same as commit 2. git add -u - modified file and deleted file add to git index but add file will not add to index repository will stop update file which has been delete 3. git add -A - = git add -u + git add . ---- ### when we develop new feature we will create a new branch on develop branch ```code=git git checlout develop git checkout -b newbranch_name ``` now we start developing our new feature ---- after we finish our new feature we should merge our new branch to develop branch ```code=git git checkout develop ``` ---- when we are merging we may have some conflict rebase also ![](https://i.imgur.com/5tFnAmG.png) ---- merge to develop branch and delete new branch ```code=git git checkout develop git merge --no-ff newbranch_name git branch -d newbranch_name ``` !!give up new branch ```code=git git checkout develop git branch -D newbranch_name ``` ---- merge develop branch to master branch let project become to release version ```code=git git checkout master git merge --no-ff develop ``` --- # git GUI ---- ### Create new repository after click this option program will ask me a folder directory,and git will create a folder dirctory in git repository like(git init) ---- ### Clone Existing repository this option progem will ask me a folder directory and Exisiting repository directory ---- ### Open Existing repository open a existing repository , we must enter a git repository directory,Git GUI will switch this folder directory and work it,like(cd) ---- ### create .gitignore after we create a repository ![](https://i.imgur.com/vpUu5cp.png) ---- ![](https://i.imgur.com/nauT0ix.png) ---- ![](https://i.imgur.com/sZE9JNx.png) ---- ##### use gitk in git GUI ![](https://i.imgur.com/YcKq9Xg.png) ---- ##### [Database statistics] [Compress Database] [Verify Database ![](https://i.imgur.com/heWCLCm.png) like git gc ---- ### Browse Branch_name Files Browse this specify branch file ---- ### Browse Branch Files Can choose branch which we want to browse --- # git GUI create branch and merge ---- Branch option 1. Create - it can create a new branch ##### supplyment [checkout after creation] option default(yes) - after create branch will switch to new branch automatically ---- 2. Checkout can switch to the other branch and can hover to file observe their version infromation ---- 3. Delete delete your branch now you switched default if this branch hasn,t merged git will waring you and stop to delete branch,if we confirm to delete this branch can press [Always (Do not perform merge checks)] abort to delete branch ---- 4. Reset take out all file from local branch newest commit_node and cover all the folder file and git will waring you when you reset ---- ##### supplyment Before press [Reset] i suggest you can press [Rescan] to check folder file isn,t it or not has it edit ---- ### Branch merge Local Merge - assume we merge A to B 1.we [Checkout] brnch B 2.[LocalMerge] click branch A and Merge 3.if have merge conflict - can give up merge - or abort merge and edit file merge again --- # SmartGit Program SmartGit like Git GUI they are use GUI to operate,differently SmartGit support more full Git function,but like this SmartGit operate is more complex than Git GUI ---- [Download SmartGit](https://www.syntevo.com) ![](https://i.imgur.com/XMwQbRU.png) ---- ![](https://i.imgur.com/Q3Xekkp.png) ---- ### Basic operation create - repository > Add or Create - Initialize ---- ##### supplyment 1. HEAD(the newest commit_node) 2. working tree(git repository folder folder is tree ) 3. index(==stage or cache remove from index == instage) ---- ### open git shell right click a folder choose git bash (Open Git Shell) ---- ### add to index(stage) choose added file and stage on contray unstage ---- ### commit type messge in Commit Message and press commit button browse commit_node evolution press Log button ---- ### branch Rebase merge now we create a new banch there are two methods in following 1. Branch>Add Branch 2. Branches Window>Local Branches >Add Branch new branch will create on now we stay branch ---- Branches window can switch our checkout branch ---- ##### supplyment we don,t need let SmartGit execute continuelly , if we have a time no need to operate SmartGit,we can close SmartGit,when use it next time SmartGit will recover to last condition no matter what program you operate Git Bash Git GUI SmartGit their git condition will same,because git message is store on disk ---- when we execute git we may have some error 1. edit operate explaination after executing commit - Local>Edit Last Commit Message to edit explaination 3. delete this time commit after operate commit - Local>Undo Last Commit delete commit data and Undo commit_node file will send to git index 5. let git repository recover to someone specify commit_node - revert - take out old file from old commit_node - Revert can create new commit_node - reset - Git remove disk - soft mode(only change repository) - mixed mode(change repository and index) - hard mode(all of them change) ---- ### Rebase - press [Rebase HEAD to ] button to rebase - recover to before rebase condition [Tools > Open Git-Shell] - if edit two branch same file will cause conflictt at this time we execute Rebase will lose ,we should back to SmartGit Files Window will show Conflicted condition file and we edit them and press [Save] button finally register them to git index and rebase it - deal with all the conflict Branch>Rebase>Continue can complete Rebase - give up rebase (Branch >Rebase>Abort) ---- ##### when project complete develop we should merge them to the original branch 1. switch to develop branch press Log button 2. choose newest commit_node to merge in commit evolution graph 3. merge method[Fast-Forward/Create Merge-Commit] 4. conflict condition we can give up back to SmartGit press Abort Merge --- # Use SourceTree Program another GUI is FREE and Functional [Download](https://www.sourcetreeapp.com/) ---- ### create ![](https://i.imgur.com/0mItcqQ.png) ---- ![](https://i.imgur.com/eLugb5M.png) ----- ### Branch Rebase and Merge ![](https://i.imgur.com/P3fsqMn.png) ---- ![](https://i.imgur.com/T0Q0fvT.png) ---- ### edit commit 1. after execute commit edit work explaination - press Source Tree Commit button >Commit options >Amend lastest commit 3. let git repository backup to specify commit_node - there are two methods - revert - Log>checkout commit_node>Reverse Commit - reset - Log>History Commit_node - soft - mixed - hard ---- ### Rebase Log>History commit_node>Rebase ##### conflict Rebase warning back to SourceTree >Unstage files window edit all conflict file and git add . choose main option>Actions>Continue Rebase give up rebase Actions>Abort Rebase ---- ### Merge checkout to develop branch and [Log>History] commit_node evolution and Merge ##### conflict git merge --abort //cancel merege --- # Use TortoiseGit Program TortoiseGit is also a GUI ---- ### Create repository right click project Git Create repository Here ### add to repository TortoiseGit > Check for modification> commit - all - none - Unversioned (untracked) - Success - fail(git did not exit cleanly) ---- ##### supplyment new file - git>untracked - TortoiseGit>unversioned file TortoiseGit didn,t have add to index this function,so TortoiseGit save to repository will automatically add to index Setting author email and name is option diagram[setting option] - Edit local .git/config - Edit global .git/config - Edit systemwide gitconfig ---- after save to git repository , we back to Working Tree press [refresh] button,file list will be blanked,now we observe git repository choose [Show log] will show git graph,and [All Branches] option can switch work branch if we commit new file to the repository we can press [Refresh] to present the newest git repository ---- Log Messagee box can compare file different,right click commit_node choose [compare] relate option like [Compare with base] mean compare this commit_node and second last commit_node if choose option [Blame] will show different in every line ---- ### Branch Rebase and Merge ---- ### Create branch there are two methods 1. [Create Branch] 2. Log messafe box right click commit_node choose [Create branch at this version] and enter the new branch name and check Switch to new branch this option will chechout ot new Branch automatically,if now we staying branch have file have not store in repository , Git will waring you and stop switch branch Force switch branch can check this option [Force] ---- ##### supplyment how to know we are staying branch ? method 1 - switch to Windows folder manager right click project file if folder has git repository now the second option will become [Git > Branch_name] the branch name is we are staying branch name method 2 - Log Message box cancel check [All Branches] will present now we are staying branch ---- assume we create a develop branch and we have switched it now we can start up our project Working Tree box can show which file has been edit add ot delete when we are developing we don,t need to close TortoiseGit . and now we introduce edit commit 1. edit work explaination after commit - open commit box check Message column option[Amend Last Commit] 2. let gir repository back to specfiy commit_node condition - reset let git repository remove disk open [Log Messages] box and right click commit_node and we can choose[soft mixed hard] - revert open [Log Messages] box and right click to take up file commit_node and choose [Revert change by this commit] ---- Rebase assume feature/fragment-base is create from develop branch when we are editing project on feature/fragment-base branch,develop branch is updating too, in this condition we should apply to feature/fragment-base branch that will keep project consistency. let feature/fragment-base rebase to develop branch newest commit_node ---- 1. switch to feature/fragment-base branch and open [Log Messages] box right click choose develop branch newest commit_node(to rebase this node) 2. choose option [Rebase (branch_name) onto this ...] press box Start Rebase wait for complete rebase and Done ---- when we rebasing if two branches edit the file at the same time will cause conflict , now we press [Start Rebase] button will show rebase conflict list and edit it to the normal condition and save it and press [ Mark as resolved] and press [Commit] button to complete rebase if has conflict can give up rebase press [Abort] button regret rebase ,choose [Show reflog],will show HEAD modify condition ,right click commit_node which we want to recover choose [Reset branch_name to this ...] button and choose [Hard] option to recover ---- after finish developing project we must merge them to orginal branch, now we should merge feature/fragment-base to develop branch 1. open [Log Messages] box switched to develop branch and right click choose feature/fragment-base branch newest commit_node and choose [Merge to 'develop'] 2. check [no fast forward] mean after complete merge should create a new commit_node 3. in addition ,we can use [Log Messages] box to present Git repository commit statistic graph press [Statistic ] button and choose data type and graph class --- # Basic Operate Remote Git repository so far we only learn how to store project in local(.git folder) we called local repository,aside from local repository if we should develop with other people we make a remote repository ---- ### remote repository function ![](https://i.imgur.com/cVBYL3m.png) ---- ### different with local and remote 1. local repository is store on project folder inside the hide folder .git,but remote repository is store on specify folder instead of .git ,in other word remote repository doesn,t have working tree project this mode git repository is called Bare type 2. in order to disticnt Bare type of git repository we usually named is vice file name .git for example game.git 3. we can use which we have learned git command , to observer Bare type of git repository to update in fact remote repository uncertainly need store on another computer we also can put it on our computer ---- ### Create remote repository In pratical we may create local repository at first then we decided to create remote repository Create bare type of git repository ```code=git git init --bare ``` ---- git will create these file but didn,t have .git folder ![](https://i.imgur.com/g4hU85U.png) ---- ##### supplyment in technically , normal type git repository can be remote git repository,but except special cause , we should open a project on remote repository, or we create bare type on remote repository ---- ### from remote repository copy to local repository use command ```code=git git clone ``` it is transfer data by HTTP SHH ... ---- 1. if remote repository is on our computer we execute this command to copy ```code=git git clone remote_git_path local_git_folder ``` if ignore local git repository foldername git will use remote git repository named 2. if remote git repository is on LAN another computer and share with shared folder use this command ```code=git git clone //computer_name/ remote_git_repository_path local_git_repository_folder ``` 3. if remote git repository is on Web Server and Web server is setting OK let git is executable ```code=git git clone http://Web_Server_websiteorIP/Remote_git_repository_path local_git_repository_folder ``` 4. if remote git repository is on SSH server and created a account for git program on SSH server ```code=git git clone Git_account@SSH_SERVER_websiteorip: remote_git_repository_path local_git_repository_folder ``` ---- after copy complete observe local git repository folder content, you will see a .git folder so clone folder is git repository not a Bare type ---- ### Local git repository and Remote git repository data Synchronize remote git repository and copied local git repository have parent relation In local git repository setting files have two origin attribute record to record this relation if we use [git config -l] list git setting will see ```code=git remote.origin.url=[remote git repository url] remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* ``` ---- assume we have edited local git repository,now we should send these edited files to remote git repository ```code=git git push origin branch_name ``` this command will send the specufy branch newest condition to remote git repository and save it. execute this command won,t record local git repository and remote git repository relation in setting file but add [--set-upstream (-u) ] git will record local git repository and remote git repository relationship in git setting file ```code=git git push --set-upstream origin branch_name ``` ---- after we can execute ```code=git git config -l | grep branch_name ``` find branch related setting ```code=git git branch -a ``` will see remote and local branch in each other repository ---- startwith remote branch is use to track remote git repository condition , result to share with multipeople it content may been edited in everytime, if it is happened ,the record with remote git repository in local git repository will not same with the newest condition .it is a common condition , but it is not error , the solution is to remote git repository get the newest conddition ---- ##### supplyment if we execute [git push] without any parameter,git will warning you and hint me need to add push.default setting in setting file,we can execute this command to set push.default is matching ```code=git git config --global push.default matching ``` yah, now we just enter [git push] command without any parameter , git will update remote git repository branch to newest condition from local git repository,or it won,t update it .in compare to matching , simple is more secure method,brcause it only update which branch we are staying ,it won,t update all the branch in one time. if execute [git push --all] command local git repository all branch will send to remote it repository ---- if we execute git push will show some error message to show remote git repository condition have been edited left hand side is when nobody edited file condition,this time we execute git push command local git repository content will send to remote git repository and doing merge, in this condition it won,t have any conflict right hand side is when we are editing but another people updated the remote git repository, in this time we execute git push command git will find it can not update remote git repository by fast-forward merge and give us some error message ![](https://i.imgur.com/qqjGNQZ.png) ---- to deal with this problem we can execute the following command ```code=git git pull ``` ### git pull it will execute two works 1. form remote repository get the newest data. after to complete this work,our computer remote git repository branch will get the newest data , if we should update all the branch in one time can add [--all] option 2. from remote repository merge to local git repository branch when execute the second step have confilct will waring you the solution is edit file or abort it after merge complete execute [git pull] we can execute [git push] again ,let local git repository content send to remote git repository and remote git repository will show use our merge record ---- ![](https://i.imgur.com/OIHy9pU.png) ---- git pull work step 1. update our computer remote git repositroy condition let it consist with remote git repository. 2. it can instead of [git fetch] in other word [git pull] is [git fetch + git merge](hint : git fetch --all can update all branch) different in git merge and git rebase merge will cause git_node evolution like net and complex but rebase is not,rebase will only let evolution like straight therefore obserer rebase is more easy if execute [git pull] command default set it will execute [git merge] to merge remote git repository and local git repository but added [--rebase] (-r) option ---- ```code=git git pull --rebase ``` git will use rebase instead of merge or you can do it seperatly ```code=git git fetch // =git pull 1 step git rebase origin/master // git rebase instead of git merge ``` ---- ##### supplyment we are not necessarily let local git repository every branch send to remote git repository store it,remote git repository its target is shared with multiple people,if that is private use it no needs send to remote git repository --- # Remote git repository advanced operate pratical it is not neccessary create a remote git repository at first, we may create a local ar first when need other people develop push to remote ---- ### Local git repository clone Bare type remote git repository ```code=git git clone --bare project_folder_name remote_git_repository_path ``` but it is not enough, because it won,t create origin attribute at local git repository and remote git repository relation now we use git remote setting their relation ---- ```code=git git remote add remote_git_rpository_name remote_git_repository_url ``` we just only need named remote git repository origin,now we have relation but didn,t have remote git repository track branch if execute [git branch -a] command we will only see local git repository branch ,there were not any remote git repository branch,therefore we execute following commands let git compare local and remote branch name automatically,find each branch and create branch on remote ```code=git git remote update ``` ---- ##### supplyment in fact we also can use a flexable way let git create local git repository and remote git repository relation automatically,that is after clone remote git repository delete local project next from remote clone to local even if local git repository didn,t have origin attribute, it also can execute git push but it need meet to format ```code=git git push remote_git_repository_url branch_name ``` ---- ### git remote add let us know 1. remote git repository not neccesary named origin we can use other name 2. remote git repository is not unique,we can add other match remote git repository at local git repository ---- assume origin have exist in remote git repository now we create another remote git repository,and let master and bug to branches sen to this new git repository.to complete this work we should these following step. 1. Create a bare tyoe git repository on remote computer ```code=git git init --bare git_repository_folder_name ``` 2. local computer execute these command ```code=git git remote add new-repo remote_git_repository_url //<-new-repo is our named git push -u new-repo master git push -u new-repo bug ``` ---- these two [git push] command will create [remote git repository] track branch automatically,therefore if we execute [ git branch -a]will present our git push branch [git remote add] command it,s opposite is [git remote rm]=[git remote remove] like ```code=git git remote rm remote_git_repository_name ``` ---- ![](https://i.imgur.com/Aq7bpbq.png) ---- cancel local and new-repo remote repository relation can execute [git remote re new-repo],when it delete new-repo all the branch will remove too,the recovery way is [git remote add] and [git remote update] ---- We can also change remote git repository name whenever you want ```code= git git remote rename old_name new_name ``` after change remote git repository name its related track branches name will auto update, in addition it also can change remote git repository url ```code= git git remote set-url remote_git_repository_name new_url ``` ---- present someone remote git repository detail ```code= git git remote show remote_git_repository_name ``` list local git repository corresponding all remote git repository ```code= git git ls-remote ``` present remote git repository related setting ```code= git git remote -v ``` ---- if decided remote git repository branch to delete ```code= git git push remote_git_repository_name --delete branch_name ``` --- # GitHub let program up to cloudside Some website offer store git repository service like GitHub BitBucket GitLab 1. GitHub only can create public project(private is not free) 2. BitBucket GitLan can create private project ---- ### Sign up a GitHub account [GitHub](https://github.com/) GitHub website repository is remote git repositroy our computer local git repository can by these two methods to access GitHub website remote git repository 1. By the HTTPS 2. By the SSH ---- 1. HTTPS & SSH will encrpt when transfer so they are verfy secure tranfer method 2. use HTTPS upload data ,Git will asked enter GitHub Website account and password 3. use SSH must create a pair of key (public key and private key),then public public key on the GitHub website,when upload data,GitHub will check our computer is login key or not at first,if hasn,t GitHub will reject and hint to enter the private key or has key GitHun will start to upload,in other word SSH offer computer and key protect but we can without setting key only when we execute on specify computer can upload directly is more convient ---- 4. we can switch HTTPS or SSH in everytime very flexable now we introduce how to create key and login key to GitHub website ---- 1. execute Git Bash ```code= bash ssh-keygen ``` program will ask key store directory(press enter mean accept defaul setting) create password (this is let local repository upload to GitHun need key)(press enter mean no need password) ---- 2. use file manager to observe [C:\user\user_account\.ssh] folder there are two file in there,[id_rsa] is private key [id.rsa.pub] is public key use wordeditor open public key file copy all the content 3. open browser login GitHub Website and press right small icon option settings 4. choose SSH and GPG keys option New SSH key in tilte blank type our name key blank enter public key content finally press Add SSH key it will create a key option ---- ### Use GitHub remote git repository GitHub operation is very like remote Git repository GitHub offer these features 1. we can create/edit/delete new git repository whenever we need 2. GitHub website offer graphic statistic feature to help us understand git repository update condition ---- How to use GitHub condition 1. Create a git repository on GitHub at first and cpoy to our computer let it become local git repository ---- 1. login GitHub website choose start a project 2. repository name enter repository name(folder name) press create repository button 3. it will hint us how to use GitHub command let local git repository upload to GitHub(HTTPS or SSH) 4. back to operation index Your repository district will show last you created repository ---- 5. From GitHub Website copy Git repository to our computer and open Git Bash switch to project folder execute ```code=git git clone git_repositroy_url project_folder_name ``` 6. after complete copy use cd command switch to our projet folder and execute [ git remote -v] will see related setting.if use HTTPS method remote will set HTTPS method on contray is SSH we can edit it whenever we need like ```code=git git remote set-url origin HHTPSorSSH_url ``` 7. now we can start to create project file in project foldermand use git command execute commit or create branch merge... if you want to let local git repository newest condition upload to GitHub we haved teached you ---- 8. delete GitHub wesite repository can choose repository name in index repository district then press settings will show a Delete this repository button,and website will ask you repository name then repository will be delete 9. observer git repository statistic information can according to last step enter to repository operate screen choose Insights option will show a list let us choose Observer mode ---- condition 2. create a local git repository at desktop at first,then send it to GitHub 1. login GitHub click Start a project button and enter a repository name is repository name blank finally press create repository button 2. GitHub will hint us how to upload local git repository to GitHub choose HTTPS or SSH then copy command and execute them in Git Bash switch to project folder project file will send to GitHub and set thir relation --- # Fork let Git repository divide then merge In literary fork is similar like branch Branch operate object is project Fork operate object is full git repository in other word,Fork can let git repository break down to two version ---- but in other side , Fork is similar clone Clone feature is copy git repository but what is different in each other use Clone to produce repository it won,t record where is it from,but fork will store it,s origin git repository let it can merge to it,s origin repository ---- ##### supplyment Fork isn,t from git origin,it is come from other git service website ---- ![](https://i.imgur.com/T0b1M5n.png) ---- ![](https://i.imgur.com/rvuKlN9.png) ---- ### git repository Fork and rebase nomatter GitHub,Bitbucket or GitLab they are also offer offer repository feature, due to we have learned Git Hub therefore we take example from GitHub in Fork and Pull Request.usually Fork is used to copy other people repository,but for training ,we must regist two account in GitHub,and use the other one create a code project and git repository,and use another account to Fork that repository. ---- 1. use account A login GitHub and create a git repository assume this project is named Game we edit some data in it,s local git repository then after edit we Push it to GitHub git repository(hint:In GitHub repository choose Insights > NetWork will present repository commit_node evolution) 2. use account B login GitHub,clone A,s Game repository url in GitHub website,and switch to account B and will see Game repository ,press the [Fork] button will create a same git repository in account B,this repository from Fork will present by Small icon of bifurcation to mean it is come from fork ---- 3. now we can get the repository bt Fork,clone to our computer let it become local git repository,and edit it 4. during edit Fork getting repository time,origin git repository will edit continuelly,assume we hope can get new content from origin repository let it apply to our repostiory,first we must set our Fork repository,let it know origin repository position ```code= git git remote add upstream https://github.com/origin_git_repository_owner/git_repository_name.git ``` ---- 5. use [git fetch] command get new content from specify git repository 6. after getting new content,execute [gitk --all] in git Bash observe git repository branches ,you will see a new branch remotes/upstream/master this branch is from origin repository new content 7. we can observe new content then decide to let it merge to our program or not - merge method ```code= git git checkout master git merge upstream/master ``` - rebase method ```code= git git checkout master git rebase upstream/master ``` ---- ### create Pull Request report update when we complete deceloping in Fork project,if we want it merge to origin git repository can use Pull Request method notify Git repository owner, for last example account A , assume now we create a Pull Requset in account B and send to A ---- 1. login account B in GitHub click Your repository choose need process git repository choose Pull requests option 2. click New pull requests 3. website will compare our git repository and origin git repository after check them without any problem click Create pull request ---- 4. last website need to type Pull request title and explaination after typing click Create pull request 5. switch to account A choose Pull requests will see Pull request from account B click Pull request option 6. we can observe pull request content if decide to merge to origin git repository can click Merge pull request button then click Confirm merge to complete merge git repository --- # Bitbucket is easier to use than Github Bitbucket website is like GitHub but Bitbucket has a advantage that is we can decide project is public or private --- ### register and set Bitbucket go to their website and register it Create a repositroy button will asked your repository name and choose this repository is public or private Bitbucket is same as GitHub their repository is remote git repository and also can used by HTTPS or SSH to transfer repository data and create SSH key method ,if we let our public key(produce by our computer) join to bitBucket website account we can following these steps ---- 1. login Bitbucket website and click circle head icon choose bitbucket settings 2. choose SSH keys then click Add key button it will prest Label blank and it need to enter explaination them use editor open our computer public key file then press Add key button,we also can add other computer SSH public key ---- ### use Bitbucket remote git repository assume our progression is create a git repository in Bitbucket website then copy that repository to our computer let it become local git repository ,finally begin our develop ---- 1. login Bitbucket website click Create a repository button to create a new git repository 2. now clone git repository from Bitbucket to our computer let it become local git repository,open git Bash switch to project folder execute the following command ```code= git git clone https://bitbucket.org/Bitbucket_website_account/respository_name.git git clone git@bitbucket.org:Bitbucket_website_account/repository_name.git //assume we has set SSH key ``` 3. after complete copy switch Git Bash program work directory, you will enter project folder then execute [git remote -v] will show remote related settings,if step 2 use HTTPS method to copy repository,remote mode will set HTTPS mode,in SSH method will set SSH mode,edit mode need this command [ git remote set-url] ```code= git git remote set-url origin HTTPS or SSH_url ``` ---- 4. now we can create project in this folder and commit create branch merge.... 5. delete Bitbucket website repository choose settings then scorll to button choose Delete repository then Deltet 6. observe git repository evolution graph choose commits ---- another condition create local git repositroy in our computer at first then send it to Bitbucket website to store it 1. login Bitbucket and create a new repository 2. enter this repository unfold [i have an existing project] option ,it will present git command example enter this command can send local git repostiory to Bitbucket and setting their match relation ---- ### execute Fork and Pull Request ---- 1. find needed Fork repository in Bitbucket website and clone that repository url. we only can Fork other public repository or myself 2. login Bitbucket website let needed to Fork repository url paste to browser press enter it will connect to that repository 3. press [+] choose Fork this repository fill Name blank and check [this is a private repository] or not finally press Fork repository 4. then we can clone this repository to our computer let it become local git repostiory and edit it ---- 5. if origin repository in Bitbucket has been edited ,we want it(edit) apply to our Fork repository,can use [git fetch] command let new edit download to local git repository then merge them , finally merge result upload to Bitbucket website repository 6. after we complete developing, if we want to let result merge to origin git repository,we can enter Fork repository in Bitbucket website,choose Pull requests in left hand funtion district,in Title blank enter title and add some description after finish press Create pull request buttton 7. origin git repository owner , after enter that repository,left hand side function district choose Pull requests will see a option,choose that option will show all the related infromation,if you don,t want to edit these can press Merge button or choose Decline button --- # GitLab is FREE and give you full system Bitbucket can create private git repository in free ,but GitLab has more advantage,other website need to charge part GitLab all of feature is free,not at all , it also public it,s program code,let everyone can install on their computer,create a full private GitLab website ---- ### Create a project login GitLab click New Project buttton and give it Project aname and visibility level can set this git repository is privatte or public finally click Create project button Remove Project button can delete this git repository ,GitLab also offer HTTPS and SSH these two transfer protocal,SSH method our computer need to produce a pair of public key ,after pruduction back to GitLab website choose Setting option >> button need to fill Title blank and SSH key finally press Add key button ---- GitLab is like GitHub and Bitbucket have two use condition on the website GitLab have a option list can choose use SSH or HTTPS .First condition is create a new repository a GitLab website then copy it to our computer been copied git repository isn,t full public condition,screen will hintl to enter GitLab website account and password ```code=git git clone https://gitlab.com/GitLab_website_name/repository_name.git ``` if we have set SSH key ```code= git git clone git@gitlab.com:GitLab_website_name/repository_name.git ``` ---- after finish copy open Git Bash work directoryenter project folder execute [git remote -v] will present remote related setting if use HTTPS way to copy repository remote will set HTTPS on contray Set SSH edit transfer method can execute [git remote set-url] ```code= git git remote set-url origin HTTPSorSSH_url ``` ---- now we can create project in this folder,and use commit,create branch .merge... if we want to send local git repository to GitLab website can refer CH16 if want observe git repository commit_node evolution in GitLab website can click >> graph and hover to features list and click Repository >> Graph if want check git commit statistic graph can choose Repository child list >Charts ---- second method is we create local git repository in our computer at first then send it to GitLab,first login GitLab and create a new repository then use [git remote] command set local repository relate GitLab website repository ```code= git git remote add origin HTTPSorSSH_url ``` use git push command let local git repository send to GitLab website repository ```code= git git push -u origin master ``` ---- GitLab also support Fork and Pull Request feature,but GitLab wesite Pull request called Merge request the following is operate steps 1. find needed Fork repository in GitLab copy that repositroy url ,we only can Fork other public repository or my own repository 2. login GitLab ,let needed Fork repository url paste to browser and it will connent to that repository 3. in screen under of project name has Fork button after press it the next website will present our account and choose our account will execute Fork 4. now we can copy this git repository to our computer let it become local git repository and edit ---- 5. origin repositroy has been edit in GitLab website we want apply this edite to Fork repository can use [git fetch ] let new edit download to local git repository then merge finally let merge result upload to GitLab website Fork repository 6. after we finish develop in Fork repository we want upload result merge to origin repository,can enter Fork repositroy in GitLab click >> choose merge Requests click New merge request 7. show our Fork repository and old and origin repository we must choose which branch need merge to origin repository after set up branch press Compare branches and continue button 8. in Title blank fill title and Description fill descruption press Submit merge request button this Merge Request will send to other people account 9. when other people enter this repository press >> icon will show hasn,t process Merge request click it will present merge request detail after observe data if we decide to execute merge press Merge button is fine ---- ### host a GitLab website GitLab system only can install on Linux system,if we use windows OS we must install virutal machine software and create a linux system finally install linux,but the fast way to create a own GitLab website we can go to this website download a software with linux virtual machine and set up GitLab system [link](https://bitnami.com/stack/gitlab/virtual-machine) ---- ##### supplyment if want to create virtual machine in computer ,CPU s\must be support virtualize technology,Intel virualize technology called intel virtualization Technology (intel VT) AMD called AMD virtualization AMD-V,we must set in BIOS,open CPU VM feature that we can open virtualiztiob\b to create VM ---- now use vm software open VM ,VMware Workstation Player software offer free version(non-commercial use),we can use it to open VM choose non-commercial use and Edit virtual machine settings to observe VM setting,for example add VM RAM let it more fluent after setting complete choose Play virtual machine it will start if it can not start and show these message **Unable to connect to the MKS: Too many socket connect attempts;giving up.** meaning a wallpaper service didn,t open normally,we can execute[controller>system manage tools>computer management>service and application>service] choose [VMware Authorization Service] right click start and restart VMware Workstation Player open Vm file , i think it can open normally ---- after open VM it will show a Linux OS we can use default account (AC:bitnami PW:bitnami)login ,if after operate VM need to use other window program must press ctrl and alt at the same time.after login Linux execute [ip addr show] to check its ip now we can open browser and enter linux show ip you will see GitLab website check GitLav website install related infromation [link](https://about.gitlab.com/installation/) ---- although GitLab website offer many feature,but not really all the company need such complex operate,the easier way is use remote git repository put in server and manage by specify people,develop people also, most of developer don,t need create project by their own,therefore for small company they don,t need to create GitLab website they can use HTTP serverr with Git program or SSH server with git program,even if we can use easy web folder share mechanism create remote git repository it will more easy --- # use windows share folder or git Daemon be Git server we will introduce two easier way to create remote git repository,these two ways didn,t need install any software 1. Windows OS share folder feature 2. Git daemon feature ---- ### Windows share folder be remote git repository ![](https://i.imgur.com/bpiyZpm.png) ---- if Git server is create in LAN and every developer can access windows share folder,the easiest way is create a share folder use is to store git repository 1. install Git program in be Git server computer 2. create a new folder in disk and set that as a share folder it will store Git remote repository we can name it GitRemoteRepo 3. open windons file manager right click this folder set it share condition ,even we can set who can access/read/write this folder permission ---- 4. open Git Bash switch project folder and execute this to create a remote git repository ```code= git git init --bare (project_name) ``` 5. to the other computer open Git Bash switch to project folder and execute the follow,fron remote git repository copy project (GitRemoteRepo is share folder name) ```code =git git clone //server_name/GitRemoteRepo/project_name ``` 6. now we can edit this project then file join git repository, if we send updated git repository to remote git repository we can execute the following ```code=git git push -u origin master ``` ---- The advantage of use Windows share folder is can control every user,s read/write/access individual.if we have lots of project and every user permission isn,t same,we can share folder in every project to control every project user and their permission ---- ### Use Git Deamon create Git server Git Daemon is Git built-in Web access service ,use Git Daemon didn,t need any software,only need Git command can work,but its advantage is it doesn,t have permission controll technism,in other word we just to know link url we can free to access,but we can set which project is public or not,Git Daemon is use their exclusive protocal(Git protocal) and 9418 protocal(we also can specify other port),assume our D disk have a GitRemoteRepo folder there have three project folder this project can be normal Git project (they have .git folder) or bare type Git repository if we want public these folder to other people ,we only should following these step ---- ![](https://i.imgur.com/5dF3nM7.png) ---- 1. open Git Bash 2. execute [cd "D:\GitRemoteRepo"] to switch GitRemoteRepo folder 3. execute the following command [--export-all] option meaning public the currentlly folder all the git repository ```code= git git daemon --export-all ``` 4. other computer in LAN can execute the following command in Git Bash to get out project ```code= git git clone git://ourcomputer_ip_or_url_GitRemoteRepo/Game1 ``` ---- if we want control every project is public or nor individual shounldn,t add [--export-all] this option,if we only public we want project in its [.git] child folder create a folder that name [git-daemon-export-ok] empty file,if project is bare type only create in its first folder Git Daemon only offer read permission in default,in other word ,other computer can not execute [git push ] command to edit out project this is for the security,because Git Daemon didn,t have user check feature,if we open write feature project ,everyone can edit our project ,but we want open write feature we can add [--enable=receive-pack] when we open Git Daemon that project can be edited by everyone ---- not only last page way ,but also we have others option to control Git Daemon operation 1. [--base-path='folder_path'] this oprion can simply other computer read project diretory if didn,t add this oprion,other computer need enter full path[GitRemoteRepo/game1].when we open Git Daemon add that option ```code=git git daemon --export-all --base-path='/d/GitRemoteRepo' ``` other people can use the following command to read that project ```code=git git clone git://our_computter_iporurl/Game1 ``` ---- 2. [--port=port_number] Git Daemon use 9418 to trasfer data in default,if this blocked by firewall can use this command choose other port for example ```code= git git daemon --export-all --port=80 ``` in result other computer need to use the same port ```code= git git clne git://our_computer_iporurl:port/project_directory ``` ---- 3.[--verbose] when Git Daemon operating it only show warning message in default.if want to show full message ,we can add this option when open Git Daemon ---- ##### supplyment after execute Git Daemon,Git Bash will stop operating until we press crtl and c at the same time.if we hope when we are executing Git Daemon can operate Git Bash at the same time,we only need to add [&] in last,for example [git daemon --export-all &] that Git Bash will operate in wallpaper it won,t affect Git Bash,if want stop wallpaper executing mode can use [ps] to check whicj program is working it will involve Git Daemon ,remeber its PID number and execute [kill PID_number ] to stop Git Daemon --- # use HTTP/HTTPS access Git Server code project is the most value assest for software company , it should be protect hard,therefore, in addition to store these important assest need to create a private Git Server in company and keep it hard permission for stolen. HTTP is WWW use protocal ,it is tranfer data by port 80,Git support HTTP,therefore we just need to set up Web Server it will let outside git program tranfer to Web Server inside Git program by HTTP protocal. ---- ![](https://i.imgur.com/yMMH7u0.png) ---- ### use HTTP store Git Server First we should install Git program in Server,Git program didn,t divide server and client version,then install Web Server the usually use is Apache [link](http://www.apachelounge.com/download) ---- after divcompress to specify folder(if store to other folder should edit httpd.conf) and from [start function list>application>start CMD] use cd command switch to Apache folder inside switch bin child folder to execute httpd.exe and windows OS will ask you permit or deny Apache please choose permit. now we should test Apache function is normal or not,please open browser and enter http://127.0.0.1 to test ---- ##### supplyment after execute httpd.exe Apache program will execute in background mode,stop Apache must seitch to CMD window press ctrl and c at the same time ---- now edit Apache setting let it can operate with Git program please following these step :-1: 1. create a folder where to store git repository in Server disk ,after we will put all the project in this folder,assume we create its path is C;\GitRemoteRepo 2. edit Apache setting file .it is conf child folder in Apache folder the file name is httpd.conf.after open setting file find the paragraph which start with [<Directory/] this paragragh be used to control specify directory can control bt outside user or not(default access from root directory all the file can not be accessed),but now we should find step 1 created folder and git folder let them can be accessed by outside user(latter we will plus account nd password to control)therefore the origin paragraph[<Directory></Directory>] last add these setting ---- ```code=txt #step 1 folder <Directory "C:/GitRemoteRepo"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> #Git program <Directory "C:/Program Files/Git/mingw64/libexec/git-core"> Options Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all </Directory> ``` ---- 3. add the code in last at same setting file,this code is open Git program to read Git repository.GIT_PROJECT_ROOT is setting Git repositroy directory,in addition Git program install directory need to edit as the case ```code= txt SetEnv GIT_PROJECT_ROOT C:/GitRemoteRepo SetEnv GIT_HTTP_EXPORT_ALL ScriptAliasMatch \ "(?x)^/git/(.*/(HEAD | \ info/refs | \ objects/(info/[^/]+ | \ [0-9a-f]{2}/[0-9a-f]{38}|\ pack/pack-[0-9a-f]{40}\.(pack|idx))) | git-(upload|receive-pack))$" \ "C:Program Files/Git/mingw64/libexec/git-core/git-http-backend.exe/$1" ``` ---- 4. add set at the same file,its feature is when HTTP specify read "/git" this directory need to check account and password our account and password is stored on git repository directory and named it htpasswd.[/git ] this named is fixed can not edit.Git program will let [/git] change to GIT_PROJECT_ROOT set directory in automatically.if we didn,t add this code then everybody can access this git repository ```code =txt <Location /git> AuthTpye Basic AuthName "GIT Repository" AuthUserFile "C:/GitRemoteRepo/htpasswd" Require vaild-user </Location> ``` ---- 5. now we use Apache tool program to create account file switch to CMD and use cd command switch workdirectory to Apache folder childer folder bin and execute the following ```code=cmd htpasswd -cmb C:/GitRemoteRepo/htpasswd account password ``` 6. open Git Bash switch to step 1 created folder and execute the following to create a remote git repository ```code=bash git init --bare project_name ``` ---- 7. now we should test remote git repository can bt HTTP.due to we have edited Apached setting file we must restart httpd.exe the new setting will take affect.after restart apache create test folder and switch to Git Bash let workdirectory to these test folder and execute the following use HTTP to get Remote Git repository ```code =bash git clone http://127.0.0.1/git/project_name ``` program will warning us to enter account and password then it will start to copy remote repository.due to remote git repository didn,t have any file .program will present these message it is normal ```code=bash warning: You appear tohave cloned an empty repository ``` ---- 8. now we can edit the project content in project folder and execute commit then execute the following command let new repository send to origin remote git repository ```code=bash git push -u origin master ``` ---- ### use HTTPS store Git Server HTTPS is more secure tha HTTP because HTTPS when transfering data it will encrypt it .however Apache is support HTTPS protocal only need fit setting than we can use HTTPS to access Git server and more secure please following these step 1. create certificate 2. edit Apache httpd.conf file 3. edit Apache httpd-ssl.conf ---- 1. switch to CMD (Admin authorization) and use cd command let workdirectory to Apache program folder 2. execute the following command create HTTPS certicate and meet the asked enter password twice and password should involve 4 char at least ```code= cmd bin\openssl genrsa -des3 -ou -server.key 2048 -config conf\openssl.cnf ``` ---- 3. execute the following and according to the hint enter password and related infromation ```code= cmd bin\openssl req -new -key server.key -out serveer.csr -config conf\openssl.cnf ``` ```code=txt Enter pass phrase for server keys: <- enter twice password . . (message detail) . ---- Country Name (2 Letter code) [AU]: <- EX: TW State or Province Name(full name)[Some-State] <-EX:Taiwan Locality Name(eg,city)[]:<- enter city name EX:Taipei Organization Name(eg,company)[Internet Widgits Pty Ltd]:<- can ignore Organiztion Unit Name(eg,section)[]: <- can ignore Common Name(e.g server FQDN or YOUR name)[]: <- enter host url or your name Email Address []: <- can ignore Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: <- can ignore An optional comapny name <- can ignore ``` ---- 4. execute the following enter step 2 password ```code=cmd bin\openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt ``` 5. let produced server.key renamed to server.key.old then execute the following command program will asked to enter step 2 password ```code =cmd bin\openssl rsa -in server.key.old -out server.key ``` 6. let produced server.key and server.crt move to Apache program conf child folder.now we have set up HTTPS protocal needed certification 7. edit Apache setting file httpd.conf and remove the headest three [#] character ---- ```code=txt #LoadModule socahe_shmcb_module modules/mod_socache_shmcb.so #LoadModule ssl_module modules/mod_ssl.so #Include conf/extra/httpd-ssl.conf ``` 8. restart httpd.exe let new setting take effect after open HTTPS we change [git clone] command let http cahnge to https to test,but you will find when we are copy remote git repository will present these message ```code=txt SSL certicate problem: self signed certificate ``` now this SSL certification is procude by our it isn,t author by third pary organization,and Git program will check SSL ceritification is legal or not in default, and git will present error message and stop operate we can close Git check function that is when when execute command plus [-c] option git will be force to close SSL check function then we can success to copy our project ```code=git git -c http.sslVerify=false clone https://urlorIP/git/project_name ``` ---- but when doing this function ,when we operating remote git repository every time we should add this setting everytime it is vary complex.the another method is set up on Git setting file to close SSL certification check ```code=git git config hhtp.sslVerify false ``` the command only will update the current project the other project won,t be affect,after set up we can use origin method to control remote git repository --- # Use SSH authorize and encrypt Git Server SSH is brivitation of Secure Shell is can check use premission and encrpyt and compress trasfering data Git also support SSH Git can be SSH client ,but we need a SSH Server software to undertake accunt management and encrypt and compress transfering data ---- ### SSH work technism SSH is smiliar like Web service,one side is SSH Client another is SSH Server.in specially these two side both need to create a pair of key every pair of key need two key to combine with public key and private key the public key is used to encrypt transfer data the private key is used to decrypt the encryoted data if public key and private key isn,t match that will cause can,t decrypt data.and key need to use specify tool to produce ---- ![](https://i.imgur.com/tKQUjBM.png) ---- berfore we operate SSH we must send our public key to each other no matter server or client that when other side send me data he/she can use our public to encrypt and we use our private key to decrypt ![](https://i.imgur.com/CFn89GY.png) ---- ##### supplyment the picture above is simplify result. in fact SSH key not take computer as unit is use user to distinct,in other word the same computer every different user can create their own key when different user login computer and use SSH connect they use different key ---- ### install and set up Copssh Server Copssh is SSH Server which operate in windows OS [link](https://itefix.net/copssh) it have free version and charge version,the free version only can create one SSH user account but charge version didn,t have this limit,we only need one aaccount,because Git server only need one account at first we have known SSH Server must store SSH Client private key ,but SSH Server is operating in Windows OS ,we must let outside computer pass windows OS then can access SSH Server,in other word SSH Server must connect with Windows OS account(usually we name Window account called [git]),when outside computer login will enter SSH server.we store all the SSH client private in SSH Server.that SSH server cab according outside computer send SSH data find the match private key and tell who (SSH Client) is creating connect,after checking identification it will exexcite ask outside computer git command ---- install and set up 1. create a name [git ] account in windows OS ,it no need admin permission ,now we can open computer manage program from [ console>system manage tool>computer management] choose[local user and group>user] then we can execute add user operation 2. use google search engine find copssh website download free version accept all the default setting and meet the hint create a new account ---- ##### supplyment Acctually Copssh will create two accounts in windows OS not only we create but also create a name sshd account ---- 3. execute Copssh Control Panel,screen will present Service is running message and choose Users tag and press add button ,in operating choose step 1. we have created account and check allow PKA aythentication and Allow TCP forwarding access type Linux shell and Sftp 4. install git ---- 5. now we should let copssh server can execute git feature,we need move git execvtive file and related library to Copssh child folder bin please use window file manager open(Gut install folder\mingw64\libexec\git-core) let it all file involve folder copy to Copssh folder SSH 6. create SSH client key .execute Git Bash in SSH Client and execute the command ```code=git ssh-keygen ``` program will asked the stored key directory press enter is ok and type password twice ---- ```code=txt Generating public/private rsa key pair. Enter file in whih to save the key (/c/Users/(user_account)/.ssh/id_rsa) Enter passphrase (empty for no passphrase) Enter same passphrase again ``` use file manager observe [C:\user\(user_account)\.ssh] folder you will find two file id_rsa file is private key id_res.pub file is public key.let public key file send to SSH Server computer and switch to SSH Server computer store to homedirectory .shh child folder and rename to authorized_keys ---- ##### supplyment if we want add other public key from SSH Client later.can open copssh control panel press Users tag page find Keys button press import button will present another edit window. we can use txt program at first open public key from SSH Client copy inside content and paste to this edit window press apply button it will add a new public key option if we want to delete public key please click the key at first and press delete button ---- 7. back to Copssh Control Panel program and press Status tag page press green button to stop SSH server when button turning red press it again let it restart.that the new setting will take affect.the bottom of screen button can observe SSH Server produce log message 8. now we test SSH Server can operate normally or not.To SSH Client computer execute Git Bash execute the command ```code= bash ssh git@SSH SERVER url or ip ``` ---- program will ask enter password please enter we create key password .if success to connet with SSH Server the screen will present ```code= txt $ ssh git@SSH Server url or ip Enter passphrase for key '/c/Users/user_account/.ssh/id_rsa':<- enter password last login: data and tim from IP git@SSH SERVER computere ~ <-show have logined SSH SERVER ``` to exit SSH SERVER connet can execute exit command ---- 9. test SSH Server and Git function ,switch to SSH Server computer open Git Bash program and switch to ConSSH home directory folder execute the command create a Bare type git repsitory ```code= git git init --bare project_name ``` 10. back to SSH Client computer and open Git Bash execute~ ```code= git git clone git@SSH SERVER url or ip :project_name ``` ---- program will ask to enter paswword if executee success screen will present the following message ```code= txt $git clone git@SSH SERVER url or ip :project_name Cloning into 'project_name'... Enter passphrase for key '/C/Users/user_account/.ssh/id_rsa': <- enter password warning: You appear to have cloned an empty repository. Checking connectivity ... done ``` ---- 11. finally test upload git repository function .edit project folder file at first and execute commit execute the following command let new repository content send to remote git repository ```code= git git push -u origin master <- send new repository content back Enter passphrase for key '/C/Users/user_account/.ssh/id_rsa': <- enter password Counting objects: ..., done . Writing objects: 100%(...),..., done. Total ...,reused ... To git@SSH SERVER url or ip : project_name * [new branch] master -> master ``` ---- if above of test didn,t have any problem.Yah everything all done.if executing step 8 have some SSH connect error .can try to stop SSH Server and restart it.if error again that is git part have error can try to operate git in local desktop find the problem and deal it and test remote finally supplyment,above of install step didn,t let Copssh produce key and didn,t let Copssh public key send to SSH Client.In fact SSH Server will complete them automatically 1. when open Copssh first time will produce key automatically store them to etc child folder 2. when SSH Client ask to connect if pass the identfy check Copssh will let its own public key use private key encrypt and compress them send to SSH Client 3. after SSH Client receive Copssh public key.it will store them to C:\Users\User_account\.ssh\known_hosts file after complete the above of step now both side can transfer data in each other ---