Git常用命令

来源:互联网 发布:欧洲旅游价格知乎 编辑:程序博客网 时间:2024/05/20 18:54

初始化开始命令

git init或者git clone url

配置命令

git config --global color.ui truegit config --global push.default currentgit config --global core.editor vimgit config --global user.name "~~"git config --global user.email "~~@~~.com"git config --global diff.tool meld

本地分支管理命令

// 查看本地分支列表git branch          // 切换到branchname本地分支            git checkout branchname     // checkout当前分支到一个新分支,命名为new_branch_name        git checkout -b new_branch_name     // 将当前分支合并到branchname分支中git merge branchname// 查看所有 commitsgit log// 查看当前分支的状态git status// 添加已修改的filename文件到暂存区git add filename// 添加所有已修改的文件到暂存区git add .// Tell git not to track file anymoregit rm filename// 将以添加在暂存区的文件提交到储存区git commit// 将以添加在暂存区的文件提交到储存区,并提交commit messagegit commit -m "Some commit message"// 查看当前的改变与上次commit的区别git diff// Compare current branch to some other branchgit diff branch_name

远程分支管理命令

// See list of remote repos available.git remote// 从远程仓库添加一个项目到本地git remote add orgin url// 将当前分支推送到远程仓库git push// 将当前分支推送到远程项目的master分支git push orgin master// 拉取远程仓库中的与本地分支不同的commitgit pull
1 0
原创粉丝点击