Skip to content

Intro to Git #23

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions _til/git/intro-to-git.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Introduction to Git
category: git
---
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make an introduction to Git as a version control system, what a version control system is, how git is different.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this should not be a list of commands but more an article

### Creating a New Repository
1. Create or navigate to the directory you want under version control
2. Run ```git init``` to start tracking changes

### Checking out a Remote Repository
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain what a remote is

1. Navigate to the location you want to clone the repo into
2. Run ```git clone [username@host:repo]``` to clone the repo
3. Run ```cd [repo]``` to access the repo

### Adding and Committing Files
1. Make any changes to ```[filename]```
2. Run ```git add [filename]``` to add the changes to the index
3. Alternatively, run ```git add *``` to add all changed files to the index
4. To commit these changes to the head, run ```git commit -m '[message]'```

### Push Commits to Remote Repository
1. To send the changes from the head, run ```git push origin [branch name]```
2. If you did not clone an existing remote repo and want to push to one, add it by running ```git remote add origin [server]```

### Branching
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain branching and why you should do it

1. Create a new branch for features or bug fixes by running ```git checkout -b [branch name]```
2. Switch branches by running ```git checkout [branch name]```
3. Delete branch by running ```git checkout -d [branch name]```
4. Make a branch available to others on a remote server by running ```git push origin [branch name]```

### Update and Merge
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain merging as a concept and merge conflicts as well

1. Update your local repo by running ```git pull```
2. Merge another branch into your current branch by running ```git merge [branch name]```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain stashing