好贷网好贷款

git 基础理论

发布时间:2016-12-5 20:36:09 编辑:www.fx114.net 分享查询网我要评论
本篇文章主要介绍了"git 基础理论",主要涉及到git 基础理论方面的内容,对于git 基础理论感兴趣的同学可以参考一下。

参考 http://www.open-open.com/lib/view/open1328069733264.html https://help.github.com/articles/create-a-repo     file:///E:/program-file/Git/doc/git/html/git-push.html 工作目录:就是文件所在的目录。 已跟踪文件:通过add命令添加的文件 暂存区域:git diff就是工作目录的文件和暂存区域的文件相比。这个区域估计是内存中git 仓库的副本 Git 仓库中:.git目录 git status 跟踪新文件git add README 此时再运行 git status 命令,会看到 README 文件已被跟踪,并处于暂存状态: 暂存已修改文件 git add benchmarks.rb 忽略某些文件 cat .gitignore                   # 此为注释 – 将被 Git 忽略                   *.a       # 忽略所有 .a 结尾的文件                    !lib.a    # 但 lib.a 除外                    /TODO     # 仅仅忽略项目根目录下的 TODO 文件,不包括 subdir/TODO                    build/    # 忽略 build/ 目录下的所有文件                    doc/*.txt # 会忽略 doc/notes.txt 但不包括 doc/server/arch.txt 尚未暂存的文件更新了哪些部分,不加参数直接输入 git diff  已经暂存起来的文件和上次提交时的快照之间的差异 git diff --cached 提交更新 git commit -m "Story 182: Fix benchmarks for speed" 从Git 仓库中移除某个文件 :git rm grit.gemspec 然后提交  递归删除当前目录及其子目录中所有 ~ 结尾的文件 git rm \*~ 移动文件 git mv file_from file_to 定制要显示的记录格式git log --pretty=format:"%h - %an, %ar : %s" 使用图形化工具查阅提交历史:在项目工作目录中输入 gitk 命令 修改最后一次提交 $ git commit -m 'initial commit' $ git add forgotten_file $ git commit --amend 取消已经暂存的文件 git reset HEAD 取消对工作目录中文件的修改 git checkout * 查看日志:  gitk board/boundary/nitrogen6x 简单方法: git config --global user.name "Your Name Here" git config --global user.email "[email protected]" touch README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/quanguoheme/android_hdmidongle.git git push -u origin master git fetch origin -----------------------------------------------------------------------------------------fetch方法 添加远程仓库要添加一个新的远程仓库,可以指定一个简单的名字,以便将来引用,运行 git remote add [shortname] [url]:$ git remote add pb git://github.com/paulboone/ticgit.git $ git remote -v origin git://github.com/schacon/ticgit.git pb git://github.com/paulboone/ticgit.git现在可以用字串 pb 指代对应的仓库地址了。比如说,要抓取所有 Paul 有的,但本地仓库没有的信息,可以运行 git fetch pb:$ git fetch pb remote: Counting objects: 58, done. remote: Compressing objects: 100% (41/41), done. remote: Total 44 (delta 24), reused 1 (delta 0) Unpacking objects: 100% (44/44), done. From git://github.com/paulboone/ticgit * [new branch] master -> pb/master * [new branch] ticgit -> pb/ticgit git fetch [remote-name] //此命令会到远程仓库中拉取所有你本地仓库中还没有的数据git fetch upstream //git push [remote-name] [branch-name] # Fetches any new changes from the original repository git merge upstream/master # Merges any changes fetched into your working files git clone 方式添加远程库 [email protected]:~$ git clone git://github.com/boundarydevices/u-boot-imx6.git Cloning into 'u-boot-imx6'... remote: Counting objects: 200078, done. remote: Compressing objects: 100% (36179/36179), done. remote: Total 200078 (delta 161056), reused 199999 (delta 160995) Receiving objects: 100% (200078/200078), 50.96 MiB | 1.63 MiB/s, done. Resolving deltas: 100% (161056/161056), done. [email protected]:~$ cd u-boot-imx6/ [email protected]:~/u-boot-imx6$ git checkout origin/production -b production [email protected]:/quck/uboot/boundary2_uboot/u-boot-imx6$ git remote -v origin git://github.com/boundarydevices/u-boot-imx6.git (fetch) origin git://github.com/boundarydevices/u-boot-imx6.git (push) [email protected]:/quck/uboot/boundary2_uboot/u-boot-imx6$ git remote show origin * remote origin Fetch URL: git://github.com/boundarydevices/u-boot-imx6.git Push URL: git://github.com/boundarydevices/u-boot-imx6.git HEAD branch: overview Remote branches: imx_v2013.04_3.5.7_1.0.0_alpha tracked mainline tracked master tracked overview tracked production tracked production-before-20130402 tracked production-before-20130826 tracked solo-dl-staging tracked staging tracked staging-20130225 tracked staging-before-20130529 tracked staging-before-20130818 tracked staging-before-20130826 tracked staging-h tracked staging_before_2013-06-17 tracked tmp_h tracked transitional-wip tracked Local branch configured for 'git pull': overview merges with remote overview Local ref configured for 'git push': overview pushes to overview (up to date) [email protected]:/quck/uboot/boundary2_uboot/u-boot-imx6$ origin代表远程库地址别名。 fetchPush  表示可以用这个进行fetch操作。 ----------------------------------------------------------------------------------------- 注意1:远程提交前,远程的库已经更新。则必须远程fetch到本地,然后在push。如果直接push会报错: $ git push -u origin master Username for 'https://github.com': [email protected] Password for 'https:[email protected]@github.com': To https://github.com/quanguoheme/githubtest.git  ! [rejected]        master -> master (non-fast-forward) error: failed to push some refs to 'https://github.com/quanguoheme/githubtest.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Merge the remote changes (e.g. 'git pull') hint: before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. [email protected] /F/git_test2 (master) $ $ git fetch origin remote: Counting objects: 5, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 1), reused 0 (delta 0) Unpacking objects: 100% (3/3), done. From https://github.com/quanguoheme/githubtest    7aaa9f1..1ffa546  master     -> origin/master [email protected] /F/git_test2 (master) $ git status # On branch master # Your branch and 'origin/master' have diverged, # and have 1 and 1 different commit each, respectively. #   (use "git pull" to merge the remote branch into yours) # [email protected] /F/git_test2 (master) $ git merge origin/master Merge made by the 'recursive' strategy.  README.md | 1 +  1 file changed, 1 insertion(+) [email protected] /F/git_test2 (master) $ ----------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------- -----------------------------------------------------------------------------------------

上一篇:Mono For Android安装方法及破解
下一篇:Java 多线程设计模式

相关文章

关键词: git 基础理论

相关评论