夯实是什么意思| 三点水卖读什么| 山东吃什么主食| 青岛啤酒节是什么时候| 下火吃什么药| 西洋参可以和什么一起泡水喝| 皮蛋为什么能治口腔溃疡| 韩墨池是什么电视剧| 什么是扁平足图片| lv中文名叫什么| 知行合一是什么意思| 吃什么降血脂最快最好| 女上位什么意思| 什么的鹿角| 心悸吃什么药| 外科主要看什么病| ao是什么| 晚上尿床是什么原因| 七什么八什么| 水是什么生肖| 睡觉总醒是什么原因| 月经量减少是什么原因| 为什么不建议切除脂肪瘤| 鬼子红药店里叫什么药| 膻味是什么意思| 菊苣别名叫什么| 痛经 吃什么| 血小板减少吃什么药| 希腊用什么货币| 男人身体怕冷是什么原因如何调理| 草包是什么意思| ccp抗体是什么意思| 甘油三酯高会引起什么病| 廿是什么意思| 新疆是什么民族| 秃噜皮是什么意思| 骏五行属什么| 怀孕前有什么症状| 支原体是什么意思| 手足口病忌口什么食物| 嫂嫂是什么意思| 夏天吃什么水果| 皮肤瘙痒用什么药膏| 孕妇应该吃什么蔬菜| 黄酒有什么功效与作用| 6月17日是什么星座| 牙齿黄是什么原因造成的| 2024年属什么年| 系带割掉了有什么影响| 心肾不交是什么意思| 什么贵人能治孤辰寡宿| 摸胸是什么感觉| 关塔那摩监狱为什么在古巴| 04属什么生肖| 嫡庶是什么意思| 承德有什么大学| 孕期脸上长痘痘是什么原因| 驻马店古代叫什么| 小麦什么时候播种| 维生素b2起什么作用| 智商100属于什么水平| 依波手表什么档次| 薄荷泡水喝有什么好处| 为什么会紫外线过敏| 硬化症是什么病| 浓茶喝多了有什么危害| 7月15号是什么星座| 退而求其次什么意思| 有福是什么意思| 发绀是什么意思| 机能鞋是什么意思| 河北有什么特产| 颈椎用什么字母表示| 胃糜烂吃什么药可以根治| 震颤是什么意思| 2017年属鸡的是什么命| 浅表性胃炎吃什么中药| 杜甫被后人称为什么| 是什么单位| 作精是什么意思| 蒸鱼豉油什么时候放| 吃什么水果对眼睛好| 念珠菌性阴道炎用什么药| 命格是什么| trans什么意思| 小心眼是什么意思| 高密度脂蛋白胆固醇偏低是什么原因| 盆腔积液是什么原因| 脾胃不好喝什么茶| eb病毒是什么病毒| 口臭口苦什么原因引起的| 夏至有什么习俗| 提成是什么| may是什么意思| 2013属什么生肖| 脚肿了是什么原因引起的| 9月28号什么星座| 胡巴是什么| 疱疹用什么药可以根治| 羊肉和什么一起炖最好| 精神障碍是什么病| 酷暑难当是什么意思| 身份证x代表什么| 什么食物补气血| 唇干是什么原因引起的| 九月七日是什么星座| 日本豆腐是什么材料| sakura是什么牌子| loreal是什么品牌| 纪委书记是什么级别| 绿茶是什么意思| 危如累卵是什么意思| 逆转是什么意思| 颈椎病有些什么症状| 发烧头晕吃什么药| 骨折后吃什么恢复快| 六月十三是什么日子| 为什么会有肥胖纹| 天意不可违是什么意思| 蓝色配什么色好看| 什么叫中位数| 吃什么调理卵巢早衰| 精液什么颜色正常| 甲状腺炎有什么症状表现| 五四运动是什么| 飞蛾吃什么东西| 凤尾鱼为什么突然就死| 为什么老是睡不着| 肠胃不好吃什么食物好| 颈椎间盘突出有什么症状| 老年人脚肿吃什么药| 万圣节为什么要送糖果| 政委是什么级别| 荔枝有什么好处| 为什么会基因突变| 什么是官方旗舰店| 胃溃疡吃什么药| 藿香正气水有什么功效| 三五行属什么| 济公原名叫什么| 晚上八点到九点是什么时辰| 咸鱼什么意思| 脖子黑是什么原因| 羡字五行属什么| 老心慌是什么原因| 痰多是什么原因| 月经为什么叫大姨妈| 4月1号是什么星座| 痛风能吃什么菜谱大全| 小腿酸什么原因| 胃角在什么位置图片| 唐僧代表什么生肖| 甲状腺结节有什么感觉| 耍无赖是什么意思| 吃什么东西可以减肥| 祸起萧墙的萧墙指什么| 日代表什么生肖| 香蕉吃多了有什么坏处| 安踏高端品牌叫什么| 祸起萧墙是什么意思| 双侧胸膜局限性增厚是什么意思| 什么叫肛裂| 锄禾是什么意思| 形婚是什么意思啊| 鹅肝为什么那么贵| 甲状腺功能减退是什么原因引起的| 非洲人一日三餐吃什么| 排卵期是指什么时候| 天蝎座是什么星象| 归脾丸的功效与作用治什么病| 鬼针草能治什么病| 尿道炎是什么引起的| ntr什么意思| 六冲是什么意思| 女人吃当归有什么好处| 白瓜是什么瓜| 飞机杯长什么样子| 脑梗是什么引起的| 尿白蛋白高是什么原因| 哭夫痣是什么意思| 尿液很黄是什么原因| 经常打呼噜是什么原因| 清明节什么时候| 梦见花生是什么意思| 单亲是什么意思| 梦见空棺材是什么意思| 自然生化流产是什么意思| 萝莉控是什么意思| 观音坐莲是什么意思| 肠憩室是什么意思| 独立户口需要什么条件办理| 痰湿阻滞吃什么中成药| 小孩上户口需要什么材料| 为什么会得尿毒症| 吃芒果对人有什么好处| 吃什么水果下火| 为什么肚子会胀气| 晚上饿了吃什么不长胖| 因果报应是什么意思| 唯爱是什么意思| 什么人什么己| 血糖吃什么水果| 小孩经常流鼻血是什么原因| 内裤上有黄色分泌物是什么原因| 齐活儿是什么意思| 狗为什么不能吃洋葱| category是什么意思| 子非鱼什么意思| 什么时间量血压最准确| 纸醉金迷下一句是什么| 非分之想什么意思| 不要问为什么| 1995年是什么年| 创伤是什么意思| 螃蟹的血是什么颜色的| lee是什么品牌| 窦性心律不齐什么意思| 贾蓉和王熙凤是什么关系| 抑扬顿挫什么意思| 尿囊素是什么| 想吐头晕是什么原因| 菠萝是什么意思| 新陈代谢是指什么| 稀松平常是什么意思| 脱臼是指什么从什么中滑脱| 兼职是什么| 天秤座女生什么性格| 静脉曲张吃什么药| kay是什么意思| 颇负什么什么| 右边偏头痛什么原因| 家里出现蟑螂预示什么| 男闺蜜是什么意思| 三生万物是什么意思| 做梦杀人了是什么征兆| 不将就是什么意思| 女人肝火旺吃什么好| 什么是可转债| 热锅凉油是什么意思| 口加大是什么字| 最近爆发什么病毒感染| 结膜炎挂什么科| 烫伤了抹什么| 下午5点是什么时辰| 扑感敏又叫什么名字| 诺迪康胶囊治什么病| 文胸36码是什么尺寸| 蚕丝衣服用什么洗最好| 什么是走婚| chilli是什么意思| 反酸吃什么药| 断念是什么意思| 小燕子的尾巴像什么| 种生基是什么意思| 表面抗体阳性什么意思| 后脑两侧痛是什么原因| 脑梗有什么特效药| 为什么会眼压高| 图图是什么意思| 忌什么意思| 痰核是什么意思| 惊恐症是什么病| 珍珠鸟吃什么食物| 吃头孢为什么不能喝酒| 百度
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
子宫长什么样子图片 装是什么意思 吃什么对肝好 灯塔是什么意思 什么食物含钾最高
什么叫高潮 身怀六甲是什么意思 snidel是什么牌子 白芍的功效与作用是什么 用什么刷牙能使牙齿变白
什么中药补肾 什么是体制内的工作 afi是胎儿的什么意思 阴历九月是什么星座 六月二十八是什么日子
倒班是什么意思 1951年属什么 右肾小结石是什么意思 4月6日什么星座 羊水栓塞是什么原因引起的
菲妮迪女装是什么档次hcv7jop5ns5r.cn soeasy是什么意思ff14chat.com 检查包皮挂什么科hcv8jop5ns2r.cn 尿毒症是什么原因导致的hcv8jop9ns7r.cn 黑豚肉是什么肉hcv8jop6ns7r.cn
马骝是什么意思hcv9jop0ns2r.cn 骨折可以吃什么hcv8jop0ns3r.cn 12颗珠子的手串什么意思cl108k.com 一什么毛巾hcv8jop4ns1r.cn 转移酶偏高是什么原因hcv8jop0ns2r.cn
7月10日是什么星座hcv9jop7ns1r.cn 低压高什么症状gysmod.com 大便红褐色是什么原因hcv7jop9ns7r.cn 阿尔茨海默症是什么症状shenchushe.com 顺位是什么意思hcv8jop5ns7r.cn
15度穿什么hcv8jop0ns4r.cn 感冒吃什么食物好得快hcv7jop9ns6r.cn 肺结节吃什么药好hcv9jop2ns6r.cn 什么是零和博弈hcv7jop5ns3r.cn 什么药可以消肿0735v.com
百度