You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: git-guides/git-overview.md
+6-12
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Whether or not you've worked with version control before, there are a few things
10
10
11
11
- Branches are lightweight and cheap, so it's OK to have many of them
12
12
- 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.
13
-
- 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.
13
+
- 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](/git-guides/git-push) and [pull](/git-guides/git-pull) changes to a repository and easily collaborate with others.
14
14
15
15
## Why Use Git?
16
16
@@ -42,7 +42,7 @@ The benefits of this can't be overstated. Not only does it create a safer enviro
42
42
43
43
## Getting Started With Git
44
44
45
-
Depending on your operating system, you may already have Git installed. <!--[Link to installing Git.]--> 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.*)
45
+
Depending on your operating system, you may already have [Git installed](/git-guides/install-git). 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.*)
46
46
47
47
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](https://lab.github.com/githubtraining/introduction-to-github).
48
48
@@ -56,19 +56,17 @@ Once you've created a branch, and moved the HEAD pointer to it by "checking out"
56
56
57
57
Next, save your changes. You're ready to start the commit!
58
58
59
-
<!--Image of staging area, working directory, and history-->
59
+
To start your [commit](/git-guides/git-commit), you need to let Git know what changes you'd like to include with `git add [file]`.
60
60
61
-
To start your commit, you need to let Git know what changes you'd like to include with `git add [file]`.
62
-
63
-
Once you've saved and staged the changes, you're ready to make the commit with `git commit -m "descriptive commit message"`. <!--link to commit page>
61
+
Once you've saved and staged the changes, you're ready to [make the commit](/git-guides/git-commit) with `git commit -m "descriptive commit message"`.
64
62
65
63
### Push your changes to the remote
66
64
67
65
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.
68
66
69
67
By default, `git push` only pushes the branch that you're currently checked out to.
70
68
71
-
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.
69
+
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`](/git-guides/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.
72
70
73
71
### Open a pull request
74
72
@@ -90,19 +88,15 @@ Once you and your team decide that the pull request looks good, you can merge it
90
88
91
89
If you choose not to merge the pull request, you can also close pull requests with unmerged changes.
92
90
93
-
<!--- Potentially include Git workflow illustrations.-->
94
-
<!--- “Learning Git” CTA.-->
95
-
96
91
## How to Use Git
97
92
98
93
### Learning & Mastering Git Commands
99
94
100
95
If you're getting started with Git, a great place to start is the [Git Cheat sheet](https://github.github.io/training-kit/). It's translated into many languages, [open source as a part of the `github/training-kit` repository](https://github.com/github/training-kit), and a great starting place for the fundamentals on the command line.
101
96
102
-
<!--- Very simplified breakdown of the most basic commands with clear navigation to learn more about each one (this might be a good example).-->
103
97
Some of the most important and most used commands that you'll find there are:
104
98
105
-
-`git clone [url]`: Clone (download) a repository that already exists on GitHub, including all of the files, branches, and commits.
99
+
-`git clone [url]`: [Clone](/git-guides/git-clone) (download) a repository that already exists on GitHub, including all of the files, branches, and commits.
106
100
-`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.
107
101
-`git branch`: This shows the existing branches in your local repository. You can also use `git branch [banch-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.
108
102
-`git checkout [branch-name]`: Switches to the specified branch and updates the working directory.
0 commit comments