git

git

1
2
$ git config --global user.name "Your Name"
$ git config --global user.email your.email@example.com

初始化一个新仓库,init命令


1
$ git init


把项目中的文件放到仓库中,add命令


-A 旗标的意思是所有文件
1
$ git add -A


查看暂存区中有哪些文件,status命令


1
$ git status


保存这些改动,commit命令


-m 旗标的意思是为这次提交添加一个说明
1
git commit -m "Initialize repository"


查看提交历史,log命令


1
$ git log


设置远程仓库地址


1
$ git remote add origin git@bitbucket.org:<username>/hello_app.git


推送


1
$ git push -u origin --all


分支



列出所有本地分支


1
$ git branch


命令先创建一个新分支,然后再切换到这个新分支


1
$ git checkout -b branch_name


提交现有文件中的全部改动


1
$ git commit -a -m "Improve the README file"


删除分支: git branch -d branch_name


1
$ git branch -d modify-README


放弃主题分支中的改动: git branch -D branch_name

1
2
3
4
5
6
$ git checkout -b topic-branch
$ <really screw up the branch>
$ git add -A
$ git commit -a -m "Make major mistake"
$ git checkout master
$ git branch -D topic-branch
文章目录
  1. 1. 初始化一个新仓库,init命令
  2. 2. 把项目中的文件放到仓库中,add命令
  3. 3. 查看暂存区中有哪些文件,status命令
  4. 4. 保存这些改动,commit命令
  5. 5. 查看提交历史,log命令
  6. 6. 设置远程仓库地址
  7. 7. 推送
  • 分支
    1. 1. 列出所有本地分支
    2. 2. 命令先创建一个新分支,然后再切换到这个新分支
    3. 3. 提交现有文件中的全部改动
    4. 4. 删除分支: git branch -d branch_name
    5. 5. 放弃主题分支中的改动: git branch -D branch_name
  • |