git常用操作

一、git的配置文件

在config文件中添加

[user]
    email = kero@qq.com
    name = kero

二、.gitignore

/target/
.mvn/wrapper/maven-wrapper.jar

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/build/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
View Code

三、命令

1.git branch -a 查看远程所有分支

2.git branch 查看本地分支

3.git checkout -b 本地分支名 origin/远程分支名     表示:将远程git仓库里的指定分支拉取到本地(本地不存在的分支)

4.git status查看

5.git pull origin 分支名

6.git push origin 分支名

7.合并fromdevelop分支到develop分支上:首先切换到develop分支,再执行: git merge fromdevelop

 8.git push origin :fromdevelop   //删除远程fromdevelop分支

git push origin test:master         // 提交本地test分支作为远程的master分支

git push origin test:test              // 提交本地test分支作为远程的test分支

git branch -d <BranchName>      // 删除本地分支 

9.git add -f  文件  强制把文件加到git追踪管理

10.永久存储账号和密码

git config --global credential.helper store
原文地址:https://www.cnblogs.com/kesimin/p/9936083.html