git简易的命令行入门教程
2016-12-22 18:01
429 查看
Git 全局设置:
创建 git 仓库:
已有项目?
获取git服务器上项目更新信息
从远程库down项目
其中https://git.oschina.net/masterkgw/bhAler11t.git为git库 master为分支
强行down下来
其中master为分支名
常见问题:
问题解析:
git本地新建一个分支后,必须要做远程分支关联。如果没有关联, git 会在下面的操作中提示你显示的添加关联。关联目的是如果在本地分支下操作: git pull, git push ,不需要指定在命令行指定远程的分支. 推送到远程分支后, 你只要没有显示指定, git pull 的时候,就会提示你。
解决方法:
使用命令git branch –set-upstream ;实例如下,其中debug为创建的分支
git branch –set-upstream debug origin/debug
命令的最终修改都是针对 config 文件。
使用-- set-upstream 去跟踪远程分支。
后补命令:
git clone
git clone是将github上的git仓库下载到本地。 每一个github都要相应的git地址
git 后补:
Command line instructions**重点内容**
Git global setup
git config –global user.name “youname”
git config –global user.email “youname@*.com”
Create a new repository
git clone http://git.*.com/name/demo2.git
cd demo2
touch README.md
git add README.md
git commit -m “add README”
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin http://git.*.com/name/demo2.git
git add .
git commit -m “Initial commit”
git push -u origin master
Existing Git repository
cd existing_repo
git remote add origin http://git.*.com/name/demo2.git
git push -u origin –all
git push -u origin –tags
git config --global user.name "makgw" git config --global user.email "makangguowei@163.com"
创建 git 仓库:
mkdir BhAlert cd BhAlert git init touch README.md git add README.md #提交 git commit -m "first commit" git remote add origin https://git.oschina.net/makgw/BhAler11t.git git push -u origin master
已有项目?
cd existing_git_repo git remote add origin https://git.oschina.net/makgw/BhAler11t.git git push -u origin master
获取git服务器上项目更新信息
$ git fetch <远程主机名> <分支名> 比如,取回origin主机的master分支。 $ git fetch origin master
从远程库down项目
$ git pull https://git.oschina.net/masterkgw/bhAler11t.git master
其中https://git.oschina.net/masterkgw/bhAler11t.git为git库 master为分支
强行down下来
git pull origin master --allow-unrelated-histories
其中master为分支名
常见问题:
Git新建本地分支与远程分支关联问题:git branch --set-upstream git在本地新建分支, push到remote服务器上之后,再次pull下来的时候,如果不做处理会报以下提示: You asked me to pull without telling me which branch you want to merge with, and 'branch.production.merge' in your configuration file does not tell me, either. Please specify which branch you want to use on the command line and try again (e.g. 'git pull <repository> <refspec>'). See git-pull(1) for details. If you often merge with the same branch, you may want to use something like the following in your configuration file: [branch "debug"] remote = <nickname> merge = <remote-ref> [remote "<nickname>"] url = <url> fetch = <refspec> See git-config(1) for details.
问题解析:
git本地新建一个分支后,必须要做远程分支关联。如果没有关联, git 会在下面的操作中提示你显示的添加关联。关联目的是如果在本地分支下操作: git pull, git push ,不需要指定在命令行指定远程的分支. 推送到远程分支后, 你只要没有显示指定, git pull 的时候,就会提示你。
解决方法:
使用命令git branch –set-upstream ;实例如下,其中debug为创建的分支
git branch –set-upstream debug origin/debug
命令的最终修改都是针对 config 文件。
使用-- set-upstream 去跟踪远程分支。
后补命令:
git clone
git clone是将github上的git仓库下载到本地。 每一个github都要相应的git地址
git 后补:
Command line instructions**重点内容**
Git global setup
git config –global user.name “youname”
git config –global user.email “youname@*.com”
Create a new repository
git clone http://git.*.com/name/demo2.git
cd demo2
touch README.md
git add README.md
git commit -m “add README”
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin http://git.*.com/name/demo2.git
git add .
git commit -m “Initial commit”
git push -u origin master
Existing Git repository
cd existing_repo
git remote add origin http://git.*.com/name/demo2.git
git push -u origin –all
git push -u origin –tags
相关文章推荐
- Git简易的命令行入门教程:
- git简易的命令行入门教程
- git简易的命令行入门教程
- Git入门(一)简易的命令行入门教程:
- Git简易的命令行入门教程
- mac os x使用Git简易入门教程
- mac os x使用Git简易入门教程
- mac os x使用Git简易入门教程
- mac os x使用Git简易入门教程
- Git简易使用入门教程
- mac os x使用Git简易入门教程
- mac os x使用Git简易入门教程
- Mac使用Git简易入门教程
- Git简易入门教程
- mac os x使用Git简易入门教程
- 简易的命令行入门教程
- Git入门教程
- Git入门教程
- pro git 入门教程
- Git入门教程