欣五行属什么| 代孕是什么意思| 搏击是什么运动| 北京摇号什么时候开始的| nf是什么意思| 必迈跑鞋什么档次| 怀孕头三个月吃什么好| sakose是什么牌子| 爱是什么歌曲| 彩虹是什么形状| 黄豆炒什么好吃| st什么意思| 豚鼠吃什么| 背叛什么意思| 痔疮什么情况下需要做手术| 牛腩烧什么好吃| 血糖高可以吃什么主食| 高血糖吃什么蔬菜| 枫叶是什么树| 湿度大对人体有什么影响| 属马的是什么星座| 高密度脂蛋白胆固醇高是什么意思| cba新赛季什么时候开始| 紫癜是一种什么病| 酌情处理是什么意思| 梦见做饭是什么意思| 囊性结节是什么意思| 为什么床上有蚂蚁| 阑尾炎术后吃什么| 头皮痛什么原因引起的| 转卖是什么意思| 众望所归是什么意思| 手术后喝什么鱼汤最好| 崩是什么意思| 羊肉馅饺子放什么菜| 番茄和蕃茄有什么区别| 再接再厉什么意思| napoleon是什么酒| 枸杞与菊花一起泡水喝有什么功效| 玉米不能和什么食物一起吃| 欣字属于五行属什么| 左下腹疼是什么原因| 滤泡性咽炎吃什么药| 婴儿吃不饱有什么危害| 大水牛是什么意思| 杨树林是什么品牌| 湖南湖北以什么湖为界| ags是什么意思| 胃胀不消化吃什么药好| 智商120是什么水平| 脾胃虚吃什么| 蝎子吃什么| 去湿气吃什么食物好| 袢是什么意思| 寄大件用什么物流便宜| 梦见自己得了绝症预示着什么| 淋巴肿了吃什么消炎药| 49是什么意思| 指甲上白色月牙代表什么| 什么洗发水最好| molly英文名什么意思| 神经性头痛吃什么药好| 胸痛应该挂什么科| 女人出黄汗是什么原因| 9月12日是什么星座| 明朝为什么会灭亡| 丰五行属什么| 拔牙后吃什么食物最好| 细菌感染吃什么抗生素| 眼睛长结石是什么原因引起的| 户口分户需要什么条件| b超涂的液体是什么| kaws是什么牌子| 绞肠痧是什么病| 平顶山为什么叫平顶山| 什么克木| 唐氏宝宝是什么意思| 伤口好转的迹象是什么| 跳闸是什么原因| 菩提子是什么材质| 来日方长是什么意思| 心脑血管供血不足吃什么药| max是什么品牌| 9月3号什么日子| 无垢是什么意思| 日入是什么时辰| taco什么意思| 腰肌劳损看什么科| 什么蜂蜜好| 胎位loa是什么位置| 梦见蜂蜜是什么意思| 拥趸是什么意思| 吃四方是什么生肖| 腺肌症吃什么药| 军士长是什么级别| 医生为什么喜欢开地塞米松| 孩子为什么不愿意上学| 血管堵塞吃什么好疏通| 幽门螺旋杆菌什么症状| 处理是什么意思| 曼龙鱼能和什么鱼混养| 月经期吃什么水果好| 乌龙是什么意思| 出院记录是什么| 一饿就心慌是什么原因引起的| 93年属什么今年多大| 什么属相不能戴貔貅| 恩施玉露是什么茶| 九曲红梅是什么茶| 骨髓增生活跃是什么意思| 犯罪心理学属于什么专业| 朝鲜战争的起因是什么| 蜈蚣最怕什么东西| 五谷都有什么| 辅酶q10是什么东西| 容易中暑是什么原因| 黄瓜为什么叫黄瓜| 反酸是什么感觉| 梦见磕头下跪什么意思| videos是什么意思| 额头上长斑是什么原因造成的| 发炎不能吃什么东西| 宝刀未老的意思是什么| 侍妾是什么意思| 二次元文化是什么意思| 业已毕业是什么意思| 网剧是什么意思| 为什么刚小便完又有尿意| 为什么老是犯困想睡觉| 怀孕吃辣对胎儿有什么影响| 父亲节送什么好| 什么是点映| 低血糖吃什么水果| 烧心是什么原因引起的| 吃饭出汗多是什么原因| 脸上过敏是什么症状| 九天揽月是什么意思| 积液是什么| 买李世民是什么生肖| 端午节吃什么食物| 一个火一个丙念什么| 血糖高适合喝什么汤| 朱砂是什么做的| 什么是复利| 根的作用是什么| 女人味是什么| 虚构是什么意思| 静静的什么| 荷兰猪吃什么| 红牛加什么提高性功能| 大师是什么意思| 胆红素高说明什么| 流汗太多对身体有什么危害| 梦见鸡是什么意思| 不到长城非好汉的下一句是什么| 张家界莓茶有什么功效| 峰会什么时候开| 肛门瘙痒用什么药膏| 六月二号是什么星座| 秋天有什么景物| 乳头痛是什么原因| 早泄是什么症状| 偏财代表什么| 喝牛奶有什么好处| 霉菌阴道炎是什么引起的| 蛋白肉是什么东西做的| 代沟什么意思| 什么命的人会丧偶| 菠菜含什么元素最高| 甲醇是什么东西| 下岗是什么意思| 酪氨酸酶是什么东西| 梦见生小孩是什么征兆| 门道是什么意思| 吃什么可以提高血小板| 网红是什么意思| 疱疹性咽峡炎是什么引起的| 宝宝积食发烧吃什么药| 胸闷气短吃什么药| 什么时候大暑| 结核杆菌是什么| 吃什么去肝火| 涂防晒霜之前要涂什么| 虹为什么是虫字旁| 柠檬酸钠是什么| 春天的花开秋天的风是什么歌| 共号是什么意思| 血管痉挛是什么原因引起的| 易经和周易有什么区别| 美国为什么不敢打朝鲜| 快车和专车有什么区别| 阿胶是什么做的| 膝盖积液有什么症状| 咽喉炎吃什么消炎药| 枸杞子有什么功效| 牛油果什么时候吃最好| 高傲什么意思| 公分是什么| 超细旦是什么面料| 一学年是什么意思| 为什么结婚| 血脂高挂什么科| 家里为什么会有跳蚤| 物上代位性是什么意思| 一花一草一世界的下一句是什么| 红细胞分布宽度偏低是什么原因| 六盘水为什么叫凉都| 二尖瓣轻度反流是什么意思| 米氮平是什么药| 五月初九是什么星座| 我还能做什么| 黑木耳不能和什么一起吃| 打喷嚏是什么意思| 烟头属于什么垃圾| 云吞面是什么面| 节节草能治什么病| 总胆红素偏高说明什么| 做梦梦到乌龟是什么预兆| 羊传染人的病叫什么名| 不完全骨折是什么意思| 医生规培是什么意思| 感康是什么| 腰果不能和什么一起吃| 脑血管痉挛是什么症状| 什么是有氧运动包括哪些| 毕业送什么礼物给老师| 风信子的花语是什么| 97年属什么今年多大| 做背有什么好处及作用| 为什么睡觉流口水| 七里香是什么| 突然头疼是什么原因| 离婚要什么手续| 葡萄糖偏高是什么原因| 为什么耳朵会痛| 女生私处长什么样| 者羽念什么| 一个虫一个卑念什么| 什么是君子| 高尿酸血症是什么意思| 耳耵聍是什么东西| 肚子大什么原因| 洋葱对肝脏有什么好处| 超负荷是什么意思| 宝路华手表什么档次| c13阳性是什么意思| 梦到男朋友出轨了预示什么意思| 线索是什么意思| 肛门是什么| 蚊子喜欢什么血型| 掐人中有什么作用| 学生近视配什么镜片好| 父亲坐过牢对孩子有什么影响| 射精太快吃什么药| 4月8号是什么星座| 脾胃不好挂什么科| 过敏性紫癜用什么药| 万加一笔是什么字| 破财消灾什么意思| 牙齿痛什么原因| 炉甘石是什么东西| 小孩便秘吃什么通便快| 公鸡为什么会啄人| 双十一是什么节日| 百度
Skip to content
Git remote illustration

Git Guide

Everything you need to know about Git, from getting started to advanced commands and workflows.

Quick links:

What is Git?

Git is a distributed version control software. Version control is a way to save changes over time without overwriting previous versions. Being distributed means that every developer working with a Git repository has a copy of that entire repository – every commit, every branch, every file. If you're used to working with centralized version control systems, this is a big difference!

Whether or not you've worked with version control before, there are a few things you should know before getting started with Git:

  • Branches are lightweight and cheap, so it's OK to have many of them
  • Git stores changes in SHA hashes, which work by compressing text files. That makes Git a very good version control system (VCS) for software programming, but not so good for binary files like images or videos.
  • Git repositories can be connected, so you can work on one locally on your own machine, and connect it to a shared repository. This way, you can push and pull changes to a repository and easily collaborate with others.

What is Git Written in?

The tools that make up the core Git distribution are written in C, Shell, Perl, and Tcl. You can find Git's source code on GitHub under git/git.

Why Use Git?

Version control is very important – without it, you risk losing your work. With Git, you can make a "commit", or a save point, as often as you'd like. You can also go back to previous commits. This takes the pressure off of you while you're working. Commit often and commit early, and you'll never have that gut-sinking feeling of overwriting or losing changes.

There are many version control systems out there – but Git has some major advantages.

Speed

Like we mentioned above, Git uses SHA compression, which makes it very fast.

Merge conflicts

Git can handle merge conflicts, which means that it's OK for multiple people to work on the same file at the same time. This opens up the world of development in a way that isn't possible with centralized version control. You have access to the entire project, and if you're working on a branch, you can do whatever you need to and know that your changes are safe.

Cheap branches

Speaking of branches, Git offers a lot of flexibility and opportunity for collaboration with branches. By using branches, developers can make changes in a safe sandbox.

Instead of only committing code that is 100% sure to succeed, developers can commit code that might still need help. Then, they can push that code to the remote and get fast feedback from integrated tests or peer review.

Without sharing the code through branches, this would never be possible.

Ease of roll back

If you make a mistake, it's OK! Commits are immutable, meaning they can't be changed. (Note: You can change history, but it will create new replacement commits instead of editing the existing commits. More on that later!) This means that if you do make a mistake, even on an important branch, like main, it's OK. You can easily revert that change, or roll back the branch pointer to the commit where everything was fine.

The benefits of this can't be overstated. Not only does it create a safer environment for the project and code, but it fosters a development environment where developers can be braver, trusting that Git has their back.

How Do I Use Git?

Learning Git Basics

If you're getting started with Git, a great place to learn the basic commands is the Git Cheat sheet. It's translated into many languages, open source as a part of the github/training-kit repository, and a great starting place for the fundamentals on the command line.

Some of the most important and most used commands that you'll find there are:

  • git clone [url]: Clone (download) a repository that already exists on GitHub, including all of the files, branches, and commits.
  • git status: Always a good idea, this command shows you what branch you're on, what files are in the working or staging directory, and any other important information.
  • git branch: This shows the existing branches in your local repository. You can also use git branch [branch-name] to create a branch from your current location, or git branch --all to see all branches, both the local ones on your machine, and the remote tracking branches stored from the last git pull or git fetch from the remote.
  • git checkout [branch-name]: Switches to the specified branch and updates the working directory.
  • git add [file]: Snapshots the file in preparation for versioning, adding it to the staging area.
  • git commit -m "descriptive message": Records file snapshots permanently in the version history.
  • git pull: Updates your current local working branch with all new commits from the corresponding remote branch on GitHub. git pull is a combination of git fetch and git merge.
  • git push: Uploads all local branch commits to the remote.
  • git log: Browse and inspect the evolution of project files.
  • git remote -v: Show the associated remote repositories and their stored name, like origin.

If you're looking for more GitHub-specific technical guidance, check out GitHub's help documentation or our GitHub for Developers series on YouTube.

Getting Started With the Git Workflow

Depending on your operating system, you may already have Git installed. But, getting started means more than having the software! To get started, it's important to know the basics of how Git works. You may choose to do the actual work within a terminal, an app like GitHub Desktop, or through GitHub.com. (Note: while you can interact with Git through GitHub.com, your experience may be limited. Many local tools can give you access to the most widely used Git functionalities, though only the terminal will give you access to them all.)

There are many ways to use Git, which doesn't necessarily make it easier! But, the fundamental Git workflow has a few main steps. You can practice all of these in the Introduction to GitHub Learning Lab course.

Create a branch

The main branch is usually called main. We want to work on another branch, so we can make a pull request and make changes safely. To get started, create a branch off of main. Name it however you'd like – but we recommend naming branches based on the function or feature that will be the focus of this branch. One person may have several branches, and one branch may have several people collaborate on it – branches are for a purpose, not a person. Wherever you currently "are" (wherever HEAD is pointing, or whatever branch you're currently "checked out" to) will be the parent of the branch you create. That means you can create branches from other branches, tags, or any commit! But, the most typical workflow is to create a branch from main – which represents the most current production code.

Make changes (and make a commit)

Once you've created a branch, and moved the HEAD pointer to it by "checking out" to that branch, you're ready to get to work. Make the changes in your repository using your favorite text editor or IDE.

Next, save your changes. You're ready to start the commit!

To start your commit, you need to let Git know what changes you'd like to include with git add [file].

Once you've saved and staged the changes, you're ready to make the commit with git commit -m "descriptive commit message".

Push your changes to the remote

So far, if you've made a commit locally, you're the only one that can see it. To let others see your work and begin collaboration, you should "push" your changes using git push. If you're pushing from a branch for the first time that you've created locally, you may need to give Git some more information. git push -u origin [branch-name] tells Git to push the current branch, and create a branch on the remote that matches it with the same name – and also, create a relationship with that branch so that git push will be enough information in the future.

By default, git push only pushes the branch that you've currently checked out to.

Sometimes, if there has been a new commit on the branch on the remote, you may be blocked from pushing. Don't worry! Start with a simple git pull to incorporate the changes on the remote into your own local branch, resolve any conflicts or finish the merge from the remote into the local branch, and then try the push again.

Open a pull request

Pushing a branch, or new commits, to a remote repository is enough if a pull request already exists, but if it's the first time you're pushing that branch, you should open a new pull request. A pull request is a comparison of two branches – typically main, or the branch that the feature branch was created from, and the feature branch. This way, like branches, pull requests are scoped around a specific function or addition of work, rather than the person making the changes or the amount of time the changes will take.

Pull requests are the powerhouse of GitHub. Integrated tests can automatically run on pull requests, giving you immediate feedback on your code. Peers can give detailed code reviews, letting you know if there are changes to make, or if it's ready to go.

Make sure you start your pull requests off with the right information. Put yourself in the shoes of your teammates, or even of your future self. Include information about what this change relates to, what prompted it, what is already done, what is left to do, and any specific asks for help or reviews. Include links to relevant work or conversations. Pull request templates can help make this process easy by automating the starting content of the body of pull requests.

Collaborate

Once the pull request is open, then the real fun starts. It's important to recognize that pull requests aren't meant to be open when work is finished. Pull requests should be open when work is beginning! The earlier you open a pull request, the more visibility the entire team has to the work that you're doing. When you're ready for feedback, you can get it by integrating tests or requesting reviews from teammates.

It's very likely that you will want to make more changes to your work. That's great! To do that, make more commits on the same branch. Once the new commits are present on the remote, the pull request will update and show the most recent version of your work.

Merge into main

Once you and your team decide that the pull request looks good, you can merge it. By merging, you integrate the feature branch into the other branch (most typically the main branch). Then, main will be updated with your changes, and your pull request will be closed. Don't forget to delete your branch! You won't need it anymore. Remember, branches are lightweight and cheap, and you should create a new one when you need it based on the most recent commit on the main branch.

If you choose not to merge the pull request, you can also close pull requests with unmerged changes.

Getting Started With GitHub

If you're wondering where Git ends and GitHub begins, you're not alone. They are tied closely together to make working with them both a seamless experience. While Git takes care of the underlying version control, GitHub is the collaboration platform built on top of it. GitHub is the place for pull requests, comments, reviews, integrated tests, and so much more. Most developers work locally to develop and use GitHub for collaboration. That ranges from using GitHub to host the shared remote repository to working with colleagues and capitalizing on features like protected branches, code review, GitHub Actions, and more.

The best place to practice using Git and GitHub is the Introduction to GitHub Learning Lab course.

If you already know Git and need to sign up for a GitHub account, head over to github.com.

Contribute to this article on GitHub.

Get started with git and GitHub

Review code, manage projects, and build software alongside 40 million developers.

Sign up for GitHub Sign in
查尿酸挂什么科 头眩晕看什么科 兔子和什么属相相冲 平均血小板体积低是什么原因 九四年属什么生肖
为什么手淫很快就射 金钱龟吃什么食物 sinoer是什么牌子 为老不尊是什么意思 日干是什么
免疫缺陷是什么意思 筋膜提升术是什么 吴亦凡为什么叫牛 吃什么水果补肾 苏打和小苏打有什么区别
日本打工需要什么条件 梦见老公不理我是什么意思 男人勃不起是什么原因造成的 酸菜炒什么好吃 圣旨是什么意思
接地气是什么意思hcv9jop4ns0r.cn 白羊座是什么象星座hcv7jop9ns0r.cn 愤青什么意思hcv8jop4ns7r.cn 死有余辜是什么意思hcv8jop8ns6r.cn 比翼双飞是什么意思hcv9jop2ns0r.cn
什么血型的人招蚊子hcv8jop2ns9r.cn 前胸后背疼是什么原因chuanglingweilai.com 心脏跳的快什么原因hcv9jop0ns4r.cn 天天洗头发有什么危害hcv8jop9ns1r.cn 避孕药吃了有什么副作用hcv8jop9ns5r.cn
拉缸是什么意思hcv9jop2ns0r.cn 疤痕修复用什么药膏好hcv8jop1ns9r.cn 尿液发绿是什么原因hcv8jop9ns0r.cn 横行霸道的意思是什么hcv7jop5ns6r.cn 1978年是什么命hcv7jop6ns7r.cn
无常是什么意思hcv9jop2ns7r.cn 诸多是什么意思hcv8jop5ns9r.cn 水样分泌物是什么炎症adwl56.com 吃什么长卵泡hcv9jop0ns1r.cn 下巴长痘痘是什么原因引起的hcv9jop0ns7r.cn
百度