1 Star 0 Fork 0

Jim/learngit-gitee

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
git_learning_note__hellozuizui.txt 5.85 KB
一键复制 编辑 原始数据 按行查看 历史
zui 提交于 2018-06-28 23:18 . add git learning note by hellozuizui
This is my first git learning note.
by hellozuizui
***************************************
*** git learning note ***
***************************************
******************
git setup
******************
1__setup git from git web:https://git-scm.com
2__config git user & email by CMD of windows:
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
******************
create git repository
******************
1__mddir & cd to the dir
2__create git repository by CMD cmd:
git init
******************
version management
******************
git add <filename> ____add file to stage
git rm <filename> ____remove file to stage
git commit -m "noticement" ____push stage file to workspace
git push ____push workspace file to master
git log ____view git version info & commit id
git log --pretty=oneline ____oneline display of "git log"
git log --graph --pretty=oneline --abbrev-commit ____get log with branch message display by graphics
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
____alise CMD(git log), and config log colorful
git reflog ____display all your operation of version, expect "push".You can find forward version which has been gone back
******************
version go back
******************
git reset HEAD <filename> ____undo stage file, it will not change actually file, just clean stage file which is not visible
git reset --hard HEAD ____go to current version, commit & before any change
git reset --hard HEAD~ ____go to last version
git reset --hard HEAD~~ ____go to last 2 version
git reset --hard HEAD~10 ____go to last 10 version
git reset --hard <commit id> ____go to corresponding commit id version
git checkout -- <filename> ____undo modify, all modify back to stage or workspace
******************
remote repository
******************
1__generate SSH key by CMD:
ssh-keygen -t rsa -C "<youremail@example.com>"
dir .ssh will generate 2 file: id_t=rsa & id_rsa.pub, id_rsa is private key should be secret, id_rsa.pub is public key to identify your SSH info
2__add ssh key into github
login in github,
choose "account setting"
"add ssh key": id_rsa.pub file
comfirm
3__create new repository
login in github,
"new repository"
add repository name
create
4__link repository
CMD:
git remote add origin git@github.com:<github_name>/<repository_name>.git
5__first time to push master branch
CMD:
git push -u origin master
******************
repository clone
******************
CMD:
git clone git@github.com:<github_name>/<repo_name>.git
the cmd will auto create a repo dir
******************
branch management
******************
git checkout -b <branch_name> ____create new branch & switch to it
= git branch <branch_name> ____create new branch
+ git checkout <branch_name> ____switch to branch
git checkout -b origin/<branch_name> ____create new origin branch at local, and switch to it
git branch ____show branch, the curent branch is tag with *
git branch -d <branch_name> ____delete branch
git merge <branch_name> ____merge branch: curent branch & <branch_name>, if branch merge, info will auto display at raw files which are conflicted
git merge --no-ff -m "merge with no-ff" dev ____merge current branch to master without "fast forward" mode:keep branch history in log
******************
remote management
******************
git push ____(Not recommended)useful only when you just have one branch local
git push origin <branch_name> ____push local branch to origin
git remote ____show remote info
git remote -v ____show more detal of remote
git pull ____show remote push info
git rebase ____rebase branch to one
conflict test 1:1_2
conflict test 2:2_2
******************
about conflict
******************
conflict:
1__two branch medified same file at same place or close place
no conflict:
1__two branch medified same file at dif place, and nor close to each other
2__two branch medified dif files
******************
General branch management strategies
******************
__________________________________master for main branch to release
|_____|_________|_________|___dev for beta branch to test
| |______|__|______|________<developer> for private branch to developer
|________|_________|________<feature> for actual feature branch downstream of <developer> or team
******************
break and recovery
******************
git stash ____stash files, even those not add; stash is a FILO not FIFO.
git stash apply ____recover from last stash
git stash drop ____remove stash
git stash pop ____recover from stash and remove stash
******************
tag
******************
git tag <tag_name> ____tag HEAD with <tag_name>
git tag ____show all tag info
git tag <tag_name> <version_number> ____tag <version_number> with <tag_name>
git tag -a <tag_name> -m "tag_description" ____tag <version_number> with <tag_name> & <tag_description>
git show <tag_name> ____show tag description of <tag_name>
git tag -d <tag_name> ____delete tag
git push origin <tag_name> ____push <tag_name> to remote
git push origin --tags ____push all tags to remote
git push origin :refs/tags/<tag_name> ____delete remote <tag_name>
******************
ignore
******************
1__create a file: .gitignore, and write the <file_name> in it, you will not add <file_name>
2__this use to ignore some trash file/mid process file/secret file
CMD:
git add -f <file_name> ____force to add ignore file
******************
alise
******************
git config (--global) alise.<alisement> <raw_CMD> ____alise <raw_CMD> to <alisement>, (--global) means useful for curent uesr, if no, CMD just useful for curent project
******************
build a private server
******************
TBD
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liangwanquan/learngit-gitee.git
git@gitee.com:liangwanquan/learngit-gitee.git
liangwanquan
learngit-gitee
learngit-gitee
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385