Basic Git commands
- Created by Paul Watson [Atlassian], last modified on
Nov 25, 2014
Here is a list of some basic Git commands to get you going with Git.
For more detail, check out the Atlassian Git Tutorials for a visual introduction to Git commands and workflows, including examples.
Git task | Notes | Git commands |
---|---|---|
Tell Git who you are |
Configure the author name and email address to be used with your commits. Note that Git strips some characters (for example trailing periods) from |
|
git init |
||
Create a working copy of a local repository: |
git clone /path/to/repository |
|
For a remote server, use: |
git clone username@host:/path/to/repository |
|
Add one or more files to staging (index): |
git add <filename> git add * |
|
Commit changes to head (but not yet to the remote repository): |
git commit -m "Commit message" |
|
Commit any files you've added with git add , and also commit any files you've changed since then: |
git commit -a |
|
Send changes to the master branch of your remote repository: |
git push origin master |
|
Status |
List the files you've changed and those you still need to add or commit: |
git status |
If you haven't connected your local repository to a remote server, add the server to be able to push to it: |
git remote add origin <server> |
|
List all currently configured remote repositories: | git remote -v |
|
Create a new branch and switch to it: |
git checkout -b <branchname> |
|
Switch from one branch to another: |
git checkout <branchname> |
|
List all the branches in your repo, and also tell you what branch you're currently in: |
git branch |
|
Delete the feature branch: |
git branch -d <branchname> |
|
Push the branch to your remote repository, so others can use it: |
git push origin <branchname> |
|
Push all branches to your remote repository: |
git push --all origin |
|
Delete a branch on your remote repository: |
git push origin :<branchname> |
|
Fetch and merge changes on the remote server to your working directory: |
git pull |
|
To merge a different branch into your active branch: |
git merge <branchname> |
|
View all the merge conflicts: View the conflicts against the base file: Preview changes, before merging: |
git diff <sourcebranch> <targetbranch> |
|
After you have manually resolved any conflicts, you mark the changed file: |
git add <filename> |
|
Tags |
You can use tagging to mark a significant changeset, such as a release: |
git tag 1.0.0 <commitID> |
CommitId is the leading characters of the changeset ID, up to 10, but must be unique. Get the ID using: |
git log |
|
Push all tags to remote repository: |
git push --tags origin |
|
If you mess up, you can replace the changes in your working tree with the last content in head: Changes already added to the index, as well as new files, will be kept. |
git checkout -- <filename> |
|
Instead, to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it, do this: |
git fetch origin git reset --hard origin/master |
|
Search |
Search the working directory for foo() : |
git grep "foo()" |
Basic Git commands的更多相关文章
- BASIC GIT WORKFLOW
BASIC GIT WORKFLOW Generalizations You have now been introduced to the fundamental Git workflow. You ...
- [label][git-commands] Several Git Commands
The process of Git commands Operation 1. git commit -m 'fist post' Windows PowerShellCopyright (C) 2 ...
- Git Commands Quick Notes
Fetch This command is to make sure your local repository has the same knowledge of the remote-tracki ...
- Git Commands
Show ssh key file: ssh -v git@github.com
- Useful Git Commands for me
查看Git追踪的文件 git ls-files 移除远程仓库的文件夹 git rm -r --cached some-directory git commit -m "Remove th ...
- Very Good Article on How Git Commands Work
http://stackoverflow.com/questions/30038999/differences-between-commit-commit-and-push-commit-and-sy ...
- Git 初始状操作指引
You have an empty repository To get started you will need to run these commands in your terminal. Ne ...
- the core of Git is a simple key-value data store The objects directory stores all the content for your database
w https://git-scm.com/book/en/v1/Git-Internals-Plumbing-and-Porcelain Git is a content-addressable f ...
- flask程序部署在openshift上的一些注意事项
https://www.openshift.com/blogs/how-to-install-and-configure-a-python-flask-dev-environment-deploy-t ...
随机推荐
- hive新特性reflect函数介绍
reflect函数可以支持在sql中调用java中的自带函数,秒杀一切udf函数. 使用案例1:所有记录执行相同的java内置函数 hive中建一张表test_udf:column1(int),col ...
- 微信小程序开发•模块化
微信小程序的MINA框架,其实是许多前端开发技术的组合.这篇文章中,我们来简单地讨论一下模块化. 1.模块化标准 玩前端的同学大部分都知道模块化的几个标准,CommonJs / AMD / CMD.这 ...
- php文件包含漏洞(input与filter)
php://input php://input可以读取没有处理过的POST数据.相较于$HTTP_RAW_POST_DATA而言,它给内存带来的压力较小,并且不需要特殊的php.ini设置.php:/ ...
- javascript的基础(2)--数据类型介绍
1. number数据类型 所有的数字都是Number数据类型 利用typeof运算符可以返回当前数据的数据类型 特殊值:NaN not a number 不是一个数字 注意 :小数的计算可能产生丢失 ...
- [SCOI2016]幸运数字
题目描述 A 国共有 n 座城市,这些城市由 n-1 条道路相连,使得任意两座城市可以互达,且路径唯一.每座城市都有一个幸运数字,以纪念碑的形式矗立在这座城市的正中心,作为城市的象征. 一些旅行者希望 ...
- bzoj2243[SDOI2011]染色 树链剖分+线段树
2243: [SDOI2011]染色 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 9012 Solved: 3375[Submit][Status ...
- net use命令详解
net use命令详解 1)建立空连接: net use \\IP\ipc$ "" /user:"" (一定要注意:这一行命令中包含了3个空格) 2)建立非空连 ...
- struts2 可以用ognl拿到值而不可以用el拿到值的解决方法
错误debug后 得到了There is no read method for container的错误 于是我new了一个实体类 package com.unity; public class St ...
- mongoose多条件模糊查询实例
mongoose多条件模糊查询 这是今天手头项目中遇到的一个问题,关于mongoose如何实现类似于SQL中 nick LIKE '%keyword%' or email LIKE '%keyword ...
- Java HttpClient伪造请求之简易封装满足HTTP以及HTTPS请求
HttpClient简介 HTTP 协议可能是现在 Internet 上使用得最多.最重要的协议了,越来越多的 Java 应用程序需要直接通过 HTTP 协议来访问网络资源.虽然在 JDK 的 jav ...