Git常用操作命令收集:
1) 远程仓库相关命令
检出仓库:$ git clone git://github.com/jquery/jquery.git
查看远程仓库:$ git remote -v
添加远程仓库:$ git remote add [name] [url]
删除远程仓库:$ git remote rm [name]
拉取远程仓库:$ git pull [remoteName] [localBranchName]
推送远程仓库:$ git push [remoteName] [localBranchName]
2)分支(branch)操作相关命令
查看本地分支:$ git branch
查看远程分支:$ git branch -r
创建本地分支:$ git branch [name] ----注意新分支创建后不会自动切换为当前分支
切换分支:$ git checkout [name]
创建新分支并立即切换到新分支:$ git checkout -b [name]
删除分支:$ git branch -d [name] ---- -d选项只能删除已经参与了合并的分支,对于未有合并的分支是无法删除的。如果想强制删除一个分支,可以使用-D选项
合并分支:$ git merge [name] ----将名称为[name]的分支与当前分支合并
创建远程分支(本地分支push到远程):$ git push origin [name]
删除远程分支:$ git push origin :heads/[name]
我从master分支创建了一个issue5560分支,做了一些修改后,使用git push origin master提交,但是显示的结果却是'Everything up-to-date',发生问题的原因是git push origin master 在没有track远程分支的本地分支中默认提交的master分支,因为master分支默认指向了origin master 分支,这里要使用git push origin issue5560:master 就可以把issue5560推送到远程的master分支了。
如果想把本地的某个分支test提交到远程仓库,并作为远程仓库的master分支,或者作为另外一个名叫test的分支,那么可以这么做。$ git push origin test:master // 提交本地test分支作为远程的master分支
$ git push origin test:test // 提交本地test分支作为远程的test分支
如果想删除远程的分支呢?类似于上面,如果:左边的分支为空,那么将删除:右边的远程的分支。
$ git push origin :test // 刚提交到远程的test将被删除,但是本地还会保存的,不用担心
3)版本(tag)操作相关命令
查看版本:$ git tag
创建版本:$ git tag [name]
删除版本:$ git tag -d [name]
查看远程版本:$ git tag -r
创建远程版本(本地版本push到远程):$ git push origin [name]
删除远程版本:$ git push origin :refs/tags/[name]
4) 子模块(submodule)相关操作命令
添加子模块:$ git submodule add [url] [path]
如:$ git submodule add git://github.com/soberh/ui-libs.git src/main/webapp/ui-libs
初始化子模块:$ git submodule init ----只在首次检出仓库时运行一次就行
更新子模块:$ git submodule update ----每次更新或切换分支后都需要运行一下
删除子模块:(分4步走哦)
1)$ git rm --cached [path]
2) 编辑“.gitmodules”文件,将子模块的相关配置节点删除掉
3) 编辑“.git/config”文件,将子模块的相关配置节点删除掉
4) 手动删除子模块残留的目录
5)忽略一些文件、文件夹不提交
在仓库根目录下创建名称为“.gitignore”的文件,写入不需要的文件夹名或文件,每个元素占一行即可,如
target
bin
*.db
相关推荐
Starting with the basic Git commands, this book will take you on a journey to explore all the features of Git and provide you with a way to integrate Git in a team to set up Agile methods and ...
You can do more with Git than just build software. This practical guide delivers a unique ... The second part provides hands-on exercises to help developers gain a better understanding of Git commands.
Its step-by-step approach with useful information makes this course the ultimate guide to understanding and mastering Git. This course will show the road to mastery example by example, while also ...
- **Rewriting History**: Using commands like `git reset` and `git rebase`, you can rewrite parts of the commit history. This should be done carefully to avoid losing important changes. - **Disaster ...
Instead, this book provides a detailed understanding of all the features of Git that are useful when you’re using Git to manage source code for software projects. I decided on the contents by ...
【压缩包子文件的文件名称列表】"Useful-Commands-master" 提示这是一个Git仓库的主分支,通常包含README文件、源代码文件、测试文件等。我们可以期待在解压后找到以下几类文件: 1. **README**:通常会详细解释...
"useful_commands:必要时要参考的命令列表" 提供了一个集合,这些命令可能在日常工作中经常用到,尤其与Jupyter Notebook相关。Jupyter Notebook是一款强大的交互式计算环境,允许用户混合编写代码、文本和多媒体...
幻影环境 rbenv,但对于 PhantomJS。 安装 要安装最新的稳定版本: git clone -b v0.0.10 ...Some useful phantomenv commands are: exec Execute a command from a particular PhantomJS version. shell Se
Helmenv 版本管理器。 大多数代码取自以下工具: 安装 将helmenv检出到任何路径(这里是${HOME}/....Some useful helmenv commands are: local Set or show the local application-specific Helm version glob
10. **Useful Commands**:ak-cli的目的是提供一套实用的命令,这可能包括但不限于自定义脚本、自动化任务、性能监测、错误排查等,旨在提升开发者的生产力。 通过ak-cli,用户可以减少重复的手动工作,专注于更...
Linux Shell Scripting Cookbook - Third Edition by Clif Flynt ...This book will take you through useful real-world recipes designed to make your daily life easier when working with the shell.
* **Basic Commands:** Teaches how to use basic developer commands such as gzip and grep, essential for file compression and searching through files respectively. #### Navigating Linux Filesystems * *...
##### Other Useful Commands - **touch**: 修改文件的时间戳或创建空文件。 - **umask**: 设置新建文件的默认权限掩码。 - **whereis/which**: 查找命令的位置。 - **cat**: 显示文件内容。 - **chattr/chgrp/...
Some useful commands include: ```bash virsh list # List active VMs virsh start <vm-name> # Start a VM virsh destroy <vm-name> # Stop a VM virsh shutdown <vm-name> # Shut down a VM gracefully ...
This resource is particularly useful for those interested in designing embedded systems based on the Linux kernel, as it covers essential aspects of building, configuring, and customizing the kernel....
Git client Chapter 1, Introduction to Microservices, will introduce you to the microservices architecture, cloud environment, etc. You will learn the difference between a microservice based ...
Make sure you always “git pull” so you have the latest version! HARD PREREQUISITES / KNOWLEDGE YOU ARE ASSUMED TO HAVE: calculus linear algebra probability Python coding: if/else, loops, lists, ...