检查配置,配置里面包括用户名,分支路径,反正需要的配置都在里面
git config –list 查看所有配置
liuguofeng719@LGF MINGW64 /yqyw/static/static (test)
$ git config –list
core.symlinks=false
core.autocrlf=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
pack.packsizelimit=2g
help.format=html
http.sslcainfo=d:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
diff.astextplain.textconv=astextplain
rebase.autosquash=true
user.name=guofeng
user.email=liuguofeng@diligrp.com
core.autocrlf=true
gui.recentrepo=D:/IdeaProjects/yqyw
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
core.hidedotfiles=dotGitOnly
remote.origin.url=http://git3.xx.com/yqyw/static.git
remote.origin.fetch=+refs/heads/:refs/remotes/origin/
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.dev.remote=origin
branch.dev.merge=refs/heads/dev
remote.test.url=http://git3.xx.com/yqyw/static.git
remote.test.fetch=+refs/heads/:refs/remotes/test/
修改配置
vi .git/config
git config –global user.name “guofeng” 配置git用户名
1,创建远程分支,首先创建本地分支,在推送到远程
git branch -b guofeng
git push origin guofeng:guofeng
拉取远程分支到本地分支
$ git pull origin test:test
Username for ‘http://git3.xx.com‘: guofeng
Password for ‘http://guofeng@git3.nong12.com‘:
From http://git3.xx.com/yqyw/static
* [new branch] test -> test
Already up-to-date.
2,删除远程分支
首先的切到其他分支
git checkout dev 切换到开发分支
git branch -d guofeng 删除本地分支
git push origin :guofeng 删除远程
3,添加文件,删除文件
liuguofeng719@LGF MINGW64 /yqyw/static/static (test)
$ touch test.txt //创建文件
liuguofeng719@LGF MINGW64 /yqyw/static/static (test)
$ git status //查看文件已经发生改变
On branch test
Untracked files:
(use “git add …” to include in what will be committed)
test.txt
nothing added to commit but untracked files present (use “git add” to track)
liuguofeng719@LGF MINGW64 /yqyw/static/static (test)
$ git add . //把所有新增或者修改的添加到缓存区
git add file/directory 指定文件或者目录添加
liuguofeng719@LGF MINGW64 /yqyw/static/static (test)
$ git status //添加成功 查看文件颜色变成绿色
On branch test
Changes to be committed:
(use “git reset HEAD …” to unstage)
new file: test.txt
git rm –cached test.txt 删除缓存区文件
// git commit -a 提交所有新增或者变动 -m 备注 提交本地
liuguofeng719@LGF MINGW64 /yqyw/static/static (test)
$ git commit -a -m “test”
[test 1477374] test
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test.txt
//push 到远程的分支
liuguofeng719@LGF MINGW64 /yqyw/static/static (test)
$ git push origin test
Username for ‘http://git3.xx.com‘: guofeng
Password for ‘http://guofeng@git3.nong12.com‘:
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 267 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To http://git3.nong12.com/yqyw/static.git
472143a..1477374 test -> test
//删除文件
liuguofeng719@LGF MINGW64 /yqyw/static/static (dev)
$ git rm -f test.txt //删除文件
rm ‘test.txt’
liuguofeng719@LGF MINGW64 /yqyw/static/static (dev)
$ git commit -m “del test.txt” //提交到暂存区
[dev 50503ab] del test.txt
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 test.txt
liuguofeng719@LGF MINGW64 /yqyw/static/static (dev)
$ git push //推送到远程
warning: push.default is unset; its implicit value has changed in
Git 2.0 from ‘matching’ to ‘simple’. To squelch this message
and maintain the traditional behavior, use:
git config –global push.default matching
To squelch this message and adopt the new behavior now, use:
git config –global push.default simple
When push.default is set to ‘matching’, git will push local branches
to the remote branches that already exist with the same name.
Since Git 2.0, Git defaults to the more conservative ‘simple’
behavior, which only pushes the current branch to the corresponding
remote branch that ‘git pull’ uses to update the current branch.
See ‘git help config’ and search for ‘push.default’ for further information.
(the ‘simple’ mode was introduced in Git 1.7.11. Use the similar mode
‘current’ instead of ‘simple’ if you sometimes use older versions of Git)
Username for ‘http://git3.xx.com‘: guofeng
Password for ‘http://guofeng@git3.nong12.com‘:
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 222 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
To http://git3.xx.com/yqyw/static.git
1477374..50503ab dev -> dev
4,合并分支
把test分支合并到dev
首先切换到dev分支
使用git merge test 意思就是把test 合并到dev分支
liuguofeng719@LGF MINGW64 /yqyw/static/static (test)
$ git checkout dev //切换到dev分支
Switched to branch ‘dev’
Your branch is up-to-date with ‘origin/dev’.
liuguofeng719@LGF MINGW64 /yqyw/static/static (dev)
$ git merge test //合并分支
Updating 472143a..1477374
Fast-forward
test.txt | 0
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test.txt
liuguofeng719@LGF MINGW64 /yqyw/static/static (dev)
$ git push origin dev //推送到远程服务器
Username for ‘http://git3.xx.com‘: guofeng
Password for ‘http://guofeng@git3.xx.com‘:
Total 0 (delta 0), reused 0 (delta 0)
To http://git3.xx.com/yqyw/static.git
1477374..50503ab dev-> dev
5,忽略文件操作
vim .gitignore 增加需要忽略的文件或者文件夹