Git 常用命令

来源:互联网 发布:优化排名软件 编辑:程序博客网 时间:2024/06/06 00:49

Git 命令

mkdir Test 创建目录
git init and git clone ssh://xxxx 初始化本地仓库并下载远程项目
echo “first file” >>README 创建文件并输入内容
cat README 查看文件内容
Git add . /将当前修改的文件添加到暂存区
Git commit -m “注释” 提交文件并说明内容
Git remote add origin ssh://…./Test. 将本地仓库添加到远程仓库 并将本地分支跟踪到远程分支
Git status -s 查看本地仓库修改状态
git branch -a 查看本地和远程分支
git checkout -b 【branch】 新建一个分支并切换到该分支
git push -u origin/remote_branch 远程已有remote_branch分支但未关联本地分支local_branch且本地已经切换到local_branch
git push origin local_branch:remote_branch 远程没有有remote_branch分支并,本地已经切换到local_branch
git branch -d local_branch 删除本地分支local_branch
git push origin :remote_branch 删除远程分支remote_branch
git fetch 更新远程分支
Git checkout -b dev origin/dev 作用checkout远程dev分支,在本地起名dev分支,并切换到本地dev 分支
git checkout dev 切换到本地dev分支
git push origin master 推送更新到远程服务器
git pull origin master 拉取指定分支代码
git rm —cached readme.txt 仅在暂存区删除,保留文件到本地目录,不追踪
git mv readme.txt readme 重命名文件
git cherry-pick “38361a68” 合并分支的某次提交(commits)
git merge develop 合并指定分支到当前分支
git stash: 备份当前的工作区的内容
git stash pop: 从Git栈中读取最近一次保存的内容,恢复工作区的相关内容
git stash list: 显示Git栈内的所有备份
git stash clear: 清空Git栈备份内容

0 0
原创粉丝点击