Introduction
local library(workspace)
a folder/project in your PC
local stage(storespace)
just a file in folder .git(.git/index)
local repository
local version list,just a sub-folder in folder .git(.git/object)
remote repsitory
remote version list,like github
Procedure for creating a git project
- create a project file;
- use
git config
to config owner’suser name and e-mail
;So,if the code pushed to the remote repository,we can know the bug’s owner and then remide it. - use
git init
to initial the folder(workspace) as a git project,and then a folder called.git
will shown; - also,you can use
git clone xxx
to directly clone the code from remote repository like github;In this way,you shall ignore stape 3,and you shall usegit checkout -b branch-name
to create a branch and jump to it; - edit the code and push the code [ just show the normal shell ]
a…go to the root dictionary and open the terminial to start git operations;
b…git add filename
via the shell,we can add the files we modified to storespace;
here,you can shellgit status
,then the terminial will show that the status isstage
,and this respresent the files have been added to storespace; As what you guess,the status isunstage
while we do nothing;
c…git commit -m commit-content
via this shell,we can add the files in the storespace to local repository;
d…git push
commt the local branch in local repository to remote repository ;
Common instructions
git add
add the files modified in local library to storespace;
git checkout -b branch-name
create a branch and jump to it;
git branch branch-name
create a branch;
git commit -m
add the files in the storespace to local repository;
git status
scan what to do next step,and project status meaning the files is stage and so on;
git log
scan the commit list of local repository;
git reset
reset the project version you choose,and the version above current version will disappear;
here are some paragrames:
--soft
reset to storespace;
--mix
reset to workspace with modified content;
--hard
reset to workspace with modified content disappeared;
commit id
choose a vesion and reset with ‘hard’ paragrame;
git revert
stage ,stash or commit current modified files;and then restart a project based on pervious verison;
git clone remoteproject-link
download project from remote one;
git fetch
update local repository from remote one;
git merge choose-branch
merge choose-branch to current branch
git pull
it is hearing that replace you code with remote code,with master version
note
put the files into folder.gitignore
,this means these files will not be tracked;That is:Do not participate in git version management!!!!