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 ...
随机推荐
- [LeetCode] Most Frequent Subtree Sum 出现频率最高的子树和
Given the root of a tree, you are asked to find the most frequent subtree sum. The subtree sum of a ...
- LOB对象在数据泵导出、导入后查询对象数量发现丢失
问题描述:问题:源库的某个Schema使用数据泵Expdp元数据整体导出,在目标库导入且成功后,逻辑验证用户对象,发现缺失.分析查询后,缺失的对象,都是LOB类型(并不是所有的LOB都无法导入,是大部 ...
- [SDOI 2008]沙拉公主的困惑
Description 大富翁国因为通货膨胀,以及假钞泛滥,政府决定推出一项新的政策:现有钞票编号范围为1到N的阶乘,但是,政府只发行编号与M!互质的钞票.房地产第一大户沙拉公主决定预测一下大富翁国现 ...
- [NOI2009]变换序列
Description Input Output Sample Input 5 1 1 2 2 1 Sample Output 1 2 4 0 3 HINT 30%的数据中N≤50: 60%的数据中N ...
- [JSOI2007]祖码Zuma
题目描述 这是一个流行在Jsoi的游戏,名称为祖玛. 精致细腻的背景,外加神秘的印加音乐衬托,彷佛置身在古老的国度里面,进行一个神秘的游戏——这就是著名的祖玛游戏.祖玛游戏的主角是一只石青蛙,石青蛙会 ...
- 【HNOI2016】序列 莫队+单调栈+RMQ
Description 给定长度为n的序列:a1,a2,…,an,记为a[1:n].类似地,a[l:r](1≤l≤r≤N)是指序列:al,al+1,…,ar-1,ar.若1≤l≤s≤t≤r≤n,则称a ...
- bzoj3894
转载自http://www.cnblogs.com/rausen 3894: 文理分科 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 1338 So ...
- Android毕业设计-微圈
勤拂拭软件出品,必属精品 : 勤拂拭软件 去年做了一个类似于我的朋友圈的项目,主要功能就是用户可以实时发表自己的动态,好友可以评论点赞什么的,可以建群,聊天啊,拉黑啊,反正是一个不错的社交软件,包含服 ...
- CAN通信要注意的问题
CAN通信要注意的问题主要有: 1.参数配置 在初始化.启动.发送.接收 CAN信息时都要对CAN卡进行参数配置: (1)CAN卡的选择,我用到的是周立功的PCIE-9221,也就是DevType设备 ...
- YOLO2:实时目标检测视频教程,视频演示, Android Demo ,开源教学项目,论文。
实时目标检测和分类 GIF 图: 视频截图: 论文: https://arxiv.org/pdf/1506.02640.pdf https://arxiv.org/pdf/1612.08242.pdf ...