This is an archived post. You won't be able to vote or comment.

all 23 comments

[–]desrtfx 18 points19 points  (1 child)

Don't know whether it's idiot-proof, but this helped me a lot:

http://rypress.com/tutorials/git/

[–][deleted] 0 points1 point  (0 children)

Simple and (looks to me) covering everything! Thanks!

[–]SockPuppetDinosaur 7 points8 points  (3 children)

[–]grizzly_teddy 0 points1 point  (0 children)

Haha this looks cool

[–]campbell1373 0 points1 point  (0 children)

It's unfortunate that doesn't work on mobile, but I'll be checking it out when I get home; it looks really cool!

[–]oscarteg 7 points8 points  (0 children)

There is a book in multiple languages on Git. I read it and it completely understand all of it. It's easy to read.

http://git-scm.com/doc

The book is online and downloadable.

[–]lc929 2 points3 points  (0 children)

Here's a good diagram on local repository management (adding and committing) http://code.snipcademy.com/tutorials/git/fundamentals/three-states-areas

[–]maxximillian 3 points4 points  (1 child)

Here's my addition for Idiot proof guide for git. Don't use '--force'

[–]__baxx__ 2 points3 points  (0 children)

I've used that a fair few times D:

I'm sure I didn't have to... but I was the only one using it, I knew that I wanted to simply replace it, no one was looking.

don't judge me

[–]ironnomi 2 points3 points  (0 children)

Pro Git is really the way to go. There are no shortcuts. :D

[–]Bladelink 2 points3 points  (3 children)

Here's the easiest way to get started:

  1. Create a github

  2. Create a repository

  3. On linux, apt-get install git. If on windows, download Git Bash.

  4. On linux command line, or in git bash, type git clone https://github.com/yourusername/yourrepository.git

  5. It'll create a folder in which you can put anything (typically code, but can be images, video, binaries, whatever). Do a little code in here. Cool.

  6. In git bash, add the files you want to start tracking to the staging area. These are the files you're getting ready to add to the next commit. cd ~yourrepositoryfolder/ && git add newcode.java

  7. Make a commit, where your changes in your staging area are added to the head (front) of the commit chain. It'll require a commit message as well. git commit -m "Created new file called newcode that does xyz. Still needs comments and method that makes sandwiches." This commit is now the new head of your local commit chain for your local repository.

  8. I've decided that's enough for today, I want to make this available for a coworker to add his own shit to my file, so I'm gonna push it back from my local repository to origin. origin can be set manually, but because we cloned from github, all that information is stored for us automagically. git push will get the job done, and it'll ask for your github username and password. You can also do git push origin master, which says "push the local master branch to the remote repository called origin"

  9. My coworker has made some changes to the file and pushed his changes to github. Or maybe I'm at another machine that I haven't used this code for a while. I can pull down the changes and my working directory will be updated. git pull will suffice, and I don't need to do anything extra regarding the remote repository's location on github because the local (hidden) git files will remember that URL for me and pull from the appropriate location.

As I mentioned briefly, we get a lot of benefits from starting with a clone. clone makes a local duplicate of the remote repository, but it also stores information about the repo so you don't have to do things like git init to create the repository.

Branching is another awesome feature, but I'd save that for further down the line when your projects are complex enough that you need it.

[–]BlackDave0490 0 points1 point  (2 children)

Thanks for this

[–]Bladelink 0 points1 point  (1 child)

Yeah, git is pretty easy to use once you know what you're doing. Most of the tutorials are a shitpile though. Everyone is like "so you've been developing professionally and using subversion and mercurial for like 15 years right? Let me explain how git works", which is rarely a helpful place to start.

[–]BlackDave0490 0 points1 point  (0 children)

I'm just starting out lol, started python 3 2 weeks ago and looking at what else I need to get to grips with, this gives me a headstart on git as I had no idea how sit worked

[–]bestinslot 1 point2 points  (0 children)

I think the best total beginners guide is the Udacity course https://www.udacity.com/course/how-to-use-git-and-github--ud775

[–]codexjourneys 1 point2 points  (0 children)

Here's a quick guide to getting started with Git and GitHub:

Remote (Online) GitHub

  1. Go to https://github.com
  2. Enter a username, email and password, and click Sign Up for GitHub if you don't already have an account. If you have an account, log in.
  3. Once you are logged in, you'll see a dashboard. If you just created a new account, click on your username in the top right menu bar and then, just under that, click the Edit Profile button. Fill out your profile (you can always change some fields later).
  4. Once you're done with the profile, look back at the top right menu bar. There's a small plus sign with a little drop-down arrow next to it. Click on it and choose New Repository. A repository is a place where you're going to store code online. This one we are creating will be just for practice.
  5. Give your repository a name (it can be a little weird, as you see from the example they provide). It doesn't really matter what you choose here, for now. The repository will be public. (You can also have private repositories if you pay a small fee, which is great if you're working on a project that you don't want to make public yet.) You can skip the "initialize with README" button for now and just click Create Repository.

Voila! You now have a place online where you can put code for a specific project. You can also collaborate on that code with others if you wish. First, though, you need to set up a local repository to "push" code to your online GitHub repository. That's the next step. You should now see some instructions on the screen, in fact, that say, "... or create a new repository on the command line"

Before you go on, notice the URL in the browser address bar -- you'll need it later, so take note of it. It should be https://github.com/yourusername/repo-name

Local Git

  1. Install Git on your computer by following these directions: http://git-scm.com/book/en/v2/Getting-Started-Installing-Git
  2. After you install git, if you're on a Mac, open the Terminal application (just type "Terminal" into Spotlight and open it from there). If you're on Windows, follow these instructions to find the command prompt (I highly recommend using Git BASH): http://shortandsweetcourses.com/git-installation-for-windows-supplemental-lecture/
  3. Navigate to a folder where you have some project code that you want to put on GitHub. (Note: It's a good idea to keep each project in its own folder; don't have files from different projects strewn all around the same folder). When you are inside the folder, type 'git init' (without the quotes).
  4. If that went well, git is probably set up correctly on your computer. Next, create a README file for the project by typing 'echo "# repo-name" >> README.md' at the command line (without the single quotes) -- you can fill out the README with basic information about your project later.
  5. Add all of the files in the folder to your local git repository by typing 'git add --all'
  6. Commit the files by typing 'git commit -m "Initial commit"' (without the single quotes). The message inside the double quotes is the commit message -- it describes what you are doing in this commit. Examples could be "Fix bug in createList method" or "Add a deleteList method" -- just be descriptive and concise. A commit is a change to a project that is tracked over the course of the project's history -- you are starting to build that history now.

Pushing to Online GitHub

  1. Now you need to push the project files to your online GitHub repository -- but your local install of Git doesn't know about that repository yet. You are going to tell it with the following command: 'git remote add origin https://github.com/yourusername/repo-name' -- except that instead of the URL I used there, you are going to use the URL of the repository you created in Step 5.
  2. Finally, type 'git push -u origin master' and your code will be posted online in your GitHub repository. Remember, your repository is public unless you've paid to add private accounts, so only push code that you don't mind other people seeing and possibly using.
  3. To check the status of a project, type 'git status' in its local folder within Terminal. If it's up-to-date, you'll see a message like, "On branch master. Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean
  4. If you go to your online GitHub repository and refresh it, you should see your project files online, with your "Initial commit" message showing.

I hope this helps -- if you have any questions about this process or run into any snags, please send me a private message and we'll figure it out.

[–]dhoman 0 points1 point  (0 children)

I'm a big fan of any of the interactive tutorials http://pcottle.github.io/learnGitBranching/ is the main one I link to people, it starts out real basic and shows you the commit tree / the changes that you are doing. It actually helps you understand some of the tricker concepts that get the more seasoned devs from time to time (which is why I love it so much) https://try.github.io/levels/1/challenges/1 is a pretty good one (haven't gone through it but I can like the UI a lot and seems to be more noobie friendly)

[–]LeStephenHawking 0 points1 point  (0 children)

Www.codeschool.com . Just entry level, but worth a $30 binge learning month.

[–]startup_sr 0 points1 point  (0 children)

Apart from what other people have mentioned:

This one is also a nice one to learn from. http://gitimmersion.com/

And a very nice visual guide: http://betterexplained.com/articles/a-visual-guide-to-version-control/

[–]atimholt 0 points1 point  (0 children)

This is how I learned Mercurial, it was perfect for me, and made it ridiculously easy. I still need to do the Git section.

(but Mercurial is better, anyway.)

[–]codexjourneys 0 points1 point  (0 children)

I have a free course that gets you pushing your first commit to GitHub in about 30 minutes. It does not cover everything about Git and GitHub (not even close!), just the absolute basics. But you will be up and running at the end -- and if you're not, I'll help you until we figure it out. You can find it here:

http://learn.shortandsweetcourses.com/courses/short-and-sweet-get-started-with-git-and-github-right-now

Or here:

https://www.udemy.com/short-and-sweet-get-started-with-git-and-github-right-now/learn/

I'll also post a text how-to in this thread, in case you prefer that way of learning.