git tips
来源:互联网 发布:python运算符 编辑:程序博客网 时间:2024/06/06 00:32
1. create local remote repo(client - server):mkdir git initgit config --bool core.bare trueor just use:git init --barebare repository (there is no working copy in the bare repository - the folder contains only the actual repository data)2. git's head default set to refs/heads/master, so if you client not create master branch, the use git clone will fail. you need create master branch in client, then git push local master to servergit remote add local ~/tools/git_repo/ #will add below line to git's config file[remote "local"] url = /home/demo/tools/git_repo/ fetch = +refs/heads/*:refs/remotes/local/*git push --set-upstream local master #will add below line to git's config file[branch "master"] remote = local merge = refs/heads/mastergit config push.default upstream #using upstream's setting to push[push] default = upstreamfor example:#remote origin repo[remote "origin"] url = YOUR_REPO fetch = +refs/heads/*:refs/remotes/origin/*#branch rxx/dev_demo_test's define[branch "rxx/dev_demo_test"] remote = origin merge = refs/heads/rxx/dev_demo_test#git push will push to origin' rxx/dev_demo_test branch,[push] default = upstream3. git push not workyou should add your server url to git first, then run git push4. list which commit merge or not merge into master$ git cherry -v remotes/origin/your_repo5. git revertgit checkout <branch> To prepare for working on <branch>, switch to it by updating the index and the files in the working tree, and by pointing HEAD at the branch. Local modifications to the files in the working tree are kept, so that they can be committed to the <branch>.git checkout --detach [<branch>], git checkout [--detach] <commit> Prepare to work on top of <commit>, by detaching HEAD at it (see "DETACHED HEAD" section), and updating the index and the files in the working tree. Local modifications to the files in the working tree are kept, so that the resulting working tree will be the state recorded in the commit plus the local modifications.git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>... When <paths> or --patch are given, git checkout does not switch branches. It updates the named paths in the working tree from the index file or from a named <tree-ish> (most often a commit). In this case, the -b and --track options are meaningless and giving either of them results in an error. The <tree-ish> argument can be used to specify a specific tree-ish (i.e. commit, tag or tree) to update the index for the given paths before updating the working tree.git reset:--soft reset head--mixed reset head, reset index(stage area)--hard reset head, reset index and working tree git rebase will rewrites history. only use it in localgit merge will generate a merge commit it, make history line mess up6. save current working tree and restoregit stash git stash --all #will save all file(modify, untrack file) to stashgit stash list git stash pop vs git stash apply 7. check which tag/branch contains specified commitgit tag --contains commit_idgit branch -a --contains commit_id8. reset local repo's head to remote repo's headgit fetch origingit reset --hard origin/rxx/dev_demo_test9. reset remote repo's head to specified commit Assuming that your branch is called master both here and remotely, and that your remote is called origin you could do:git reset --hard <commit-hash>git push -f origin master10. how to revert some commitassume:A <-- B <-- C <-- D <-- master <-- HEADyou want to drop B, C, D's change;you just need checkout A, then re-commit it11. two dashThe double dash "--" means "end of command line flags" i.e. it tells the preceding command not to try to parse what comes after command line options.Suppose I have a file named path/to/file.txt in my Git repository, and I want to revert changes on it.git checkout path/to/file.txtNow suppose that the file is named master...git checkout -- master12. git list file for one commit:git diff-tree --no-commit-id --name-only -r bd61ad9813. add modified file to git:git status | awk '/modified/ {print $2}' | xargs git add14. The remote end hung up unexpectedly while git cloning:git config --global http.postBuffer 104857600015. delete remove branch:git push origin :branch_to_delete16. restore file from specific commit:git checkout <commit> <filename>17. list the diff file between two branch:git diff --name-status master branchName18. abort rebase:git rebase --abort
0 0
- git tips
- Git tips
- git tips
- Git Tips
- git tips
- git tips
- GIT tips
- git tips
- git tips谨记
- git tips - merge, revert
- git top ten tips
- git 小tips
- git rev tips
- Git使用Tips
- 常用的Git Tips
- tips pycharm 配搭git
- 关于GIT的常用TIPS
- GIT Tips (To be continued)
- Android抽象布局——include、merge 、ViewStub
- PixelFormat(像素格式)以及view的高度getX(),getRawX()以及Path所用
- jdk自带线程池详解
- 装mysql 报错 Error Nr. 1045 解决方法
- HDU5762 Teacher Bo
- git tips
- 神奇的Fastcgi_Finish_Request
- 我在做大数据处理的时候,特别是在做数据处理,我貌似总是不注意大数据的思考
- 系统集成方案(一).NET集成方案
- MVC设计模式
- 顺序表应用3:元素位置互换之移位算法
- 关于C++中静态成员函数的理解
- nodejs的后端字符串验证器-validator
- 面试题55:字符流中第一个不重复的字符