Version Control Guide (Git, GitHub)

Version Control (GitHub)

Table of Contents

Git

  • What is Git
  • How to use Git
  • By CMD and Git GUI
  • Create a repository
  • Add files to a repository
  • Commit Changes
  • Push the code
  • How to make branches for the git
  • Commit the project for the after branching ?
  • Push the code .
  • How to Merge the Branches ?

How to make Markdown ?

  • How to format text ?
  • How to format header ?
  • How to make list ?
  • How to insert Link ?
  • How to insert Images ?

How your Github Looks as a working professional as well as college Students ?

  • What points should be add in Github Portfolio ?
  • How to insert achievement ?
  • How to insert your coding achievements in that ?
  • How to use Your GitHub as a Resume ?
Imagine you're working on a big document with a friend, like a grocery list for a party. Version control is like having a superpower to keep track of all the changes made to that list.
Here's how it works:
  • Keeping Track of Changes: Every time you add an item or your friend edits the list, version control saves a copy of that version. So, if you accidentally add ten cartons of eggs instead of one, you can easily go back to an earlier version.

  • Going Back in Time: Think of it like a time machine for your files. With version control, you can rewind and see exactly what the document looked like at any point in time. This is super helpful if you need to find something that was there before or if you want to see how the document evolved.

  • Collaboration Made Easy: Imagine you and your friend are working on the list at the same time. Version control helps avoid conflicts by keeping track of who made what changes. No more fighting over who accidentally deleted the pizza!

These are like the software programs that help you use this superpower. There are many out there, but a popular one is called Git. Think of Git as a giant filing cabinet that stores all the different versions of your document (or any type of file, really) and keeps track of everything.

Here are some benefits of using version control tools:

  • No More Lost Work: Ever accidentally overwrite a file and lose all your hard work? Version control saves you from that nightmare!
  • Easy Collaboration: Version control makes working with others on projects a breeze. No more confusion about who did what.
  • Experimentation Freedom: If you’re trying out a new idea on a document, you can do it without worrying about messing up the original version. Version control lets you experiment freely!

So, version control is basically a way to keep track of all the changes made to your files over time, making it easier to collaborate, experiment, and never lose your work. Pretty cool, right?

Git

What is Git?

Git is a popular tool used for version control, kind of like a time machine for your computer files. Imagine you’re writing a story. With Git, you can save snapshots of your work at different points, so you can:

  • Go back in time: If you accidentally mess something up, you can easily revert to an earlier version where everything was fine.
  • See the history: Track how your project evolved over time, like watching a movie of your changes.
  • Work together: Multiple people can work on the same project at once, and Git helps avoid conflicts by keeping track of everyone’s changes.

Think of it as a super-powered save system for your projects, letting you collaborate easily and never lose your work.

Imagine Git as a tool to track changes in your project, like following a recipe. Here’s a simplified breakdown:

  1. Setting Up the Kitchen (Local Repository): You tell Git to start tracking a project folder on your computer. This is like getting your bowls and ingredients ready.

  2. Making Changes (Editing Files): You edit the files in your project, like chopping veggies or mixing batter.

  3. Staging Changes (Adding to Staging Area): Tell Git which specific changes you want to save permanently. Think of it as putting the chopped ingredients in a bowl, ready to be used.

  4. Taking a Snapshot (Committing): You give your changes a descriptive name and save them. This is like labeling a container with what’s inside, like “Chopped Veggies for Pizza.”

  5. Sharing Your Recipe (Pushing to Remote Repository): If you want to share your work with others (like sending the recipe to a friend), you can push your saved changes to a remote hosting service (like GitHub). This is like sending your labeled container to your friend.

  6. Getting Updates (Pulling from Remote): If your friend makes changes to the recipe (like adding more cheese!), you can pull those changes back to your local project to keep up-to-date. This is like getting their updated recipe with the extra cheese.

Remember, this is a simplified version, but it gives you the basic idea of how Git helps you track changes and collaborate on projects!

Imagine you’re writing a story and want to keep track of different drafts. That’s what Git does, but for any kind of file on your computer. Here’s the difference between using Command Prompt (CMD) and Git GUI for this:

CMD (Command Prompt):

  • Think of CMD as a cryptic friend who only speaks in codes. You have to type specific commands to tell Git what to do, like “add this change” or “go back to a previous version.” It’s powerful, but takes some practice to learn the codes.

Git GUI (Graphical User Interface):

  • This is your more visual friend. It has buttons and menus that you click on to do things. You can see the history of changes and pick versions from a list, making it easier to understand what’s going on. It’s great for beginners.

Here’s a short analogy:

  • CMD: Like using a complicated remote control to change channels on a TV. Lots of buttons, but specific for each action.
  • Git GUI: Like using a remote with pictures of the channels. Easier to navigate, but might not have all the options.

In the end, both CMD and Git GUI help you use Git to keep track of your files. Choose the one that feels more comfortable for you: the powerful-but-tricky friend (CMD) or the easy-to-understand one (Git GUI).

The steps to create a repository will depend on where you want to create it. Here are two common options:

1. Creating a repository on GitHub:

  • Sign up for a free GitHub account (if you don’t have one already).
  • Click the “+” button in the top right corner and select “New repository”.
  • Give your repository a clear and descriptive name.
  • Optionally, add a short description of what the repository is for.
  • Click “Create repository”.

2. Creating a local repository with Git:

  • Open a terminal window on your computer.
  • Navigate to the directory where you want to create your project.
  • Run the command git init to initialize a new Git repository.

That’s it! Now you have a repository to store your project files and track changes.

Adding files to your repository is like putting things in your special storage box (the one we created earlier). Here’s a quick breakdown:

  1. Have your files ready: Make sure the files you want to add are in the same folder as your repository (the special box).
  2. Tell the system to track the files: Use the magic words! In your terminal (computer program window), type git add <filename> (replace <filename> with the actual name of your file). You can also use git add . to add all the files in the current folder.
  3. Save the snapshot (commit): Once you’ve added your files, it’s like taking a picture of everything inside the box at that moment. Type git commit -m "Your message here". Replace “Your message here” with a short description of what changes you made. This helps you remember what’s in each snapshot later.

That’s it! Your files are now safely stored in your repository, with a snapshot of their state captured. You can repeat these steps whenever you make changes to your files.

Committing changes in Git is like taking a checkpoint in your project. Imagine you’re working on a building project with Legos. Every time you finish a big section, like a floor or a wall, you’d want to save your progress in case something goes wrong later.

Here’s how committing changes works:

  1. Tell Git what to save (staging): Use the git add command to tell Git which specific files or changes you want to include in your next checkpoint.
  2. Write a message (commit message): This is like a label for your checkpoint, explaining what you just accomplished. A good message helps you (and others) understand what changed in this commit.
  3. Save your progress (commit): Run the git commit command to create a new checkpoint with the staged changes and your message.

Think of it like this:

  • Staging area: Here you gather the specific Legos you want to save for this checkpoint.
  • Commit message: A note stuck to the box explaining what you built with those Legos.
  • Commit: The actual box storing those Legos for safekeeping.

By committing regularly, you:

  • Keep track of your progress: See how your project evolved over time, checkpoint by checkpoint.
  • Go back in time: If you mess something up, you can easily revert to a previous commit.
  • Collaborate clearly: When working with others, commits show everyone what changes were made and why.

So, committing changes is like saving your work at key points in your project, making it easier to track progress, fix mistakes, and work together effectively.

Pushing code is like taking your latest work from your local storage box (repository) and uploading it to a bigger, shared one online. Imagine you’ve finished your drawing and want to show it to your friends or save it for later. Pushing your code does the same thing for your project files.

Here’s a simplified breakdown:

  1. Connect the boxes (remote repository): You’ll need the web address (URL) of the online repository where you want to push your code (usually on GitHub). Think of this as the address of your friend’s house where you’ll share your drawing.
  2. Pack your stuff (create a commit): Make sure you’ve saved the latest version of your work locally (using git commit). This is like double-checking your drawing looks perfect before packing it up.
  3. Send it over (push): Use the git push command to send your local commit (packed files) to the online repository. This is like physically taking your drawing to your friend’s house.

By pushing your code, you:

  • Share your work: Make your code accessible online, allowing others to see it or collaborate on the project.
  • Backup your work: Have a safe copy of your project stored online, in case something happens to your local files.

Remember, you’ll need to have already created a repository online (like on GitHub) and set up the connection before pushing your code.

Imagine you’re working on a big project, like building a Lego castle. Branches in Git are like separate building areas. You can work on a new feature (like a fancy drawbridge) in one branch without messing up the main castle (the main branch). Here’s how to make branches:

  1. Be in the Main Room (Branch): Make sure you’re working in the main branch of your project, which usually has a name like “master” or “main”.

  2. Grab New Bricks (Create a Branch): Use the command git branch <branch_name> to create a new branch. Give it a clear name that describes what you’ll be working on in this branch (e.g., “drawbridge”).

  3. Start Building (Switch Branch): Use the command git checkout <branch_name> to switch to your new branch. Now you’re working in your separate building area.

  4. Build Your Fancy Drawbridge: Make all your changes and edits in this branch. Experiment freely without affecting the main castle.

  5. Merging Branches (Connecting Your Work): Once you’re happy with your drawbridge, you can merge it back into the main branch using another command. This combines your work from the new branch into the main project.

Branches are like a safety net for your project. They let you try out new ideas and keep your main project stable.

The concept of committing after branching depends on which branch you want the changes to be in. Here’s a breakdown for two scenarios:

Scenario 1: Committing changes to the current branch (where you are now):

  1. Stage your changes: Imagine you made some edits to your project files. Use the git add command followed by the file names (or just git add . to add all modified files) to tell Git which changes you want to include in the next commit.
  2. Write a commit message: This is a short description of what changes you made. A good message helps you (and others) understand what happened in this commit. Use git commit to open an editor where you can write your message and save it.
  3. Commit your changes: Once you save the message, Git creates a snapshot of your project with those changes. That snapshot is stored securely in your version control history.

Scenario 2: Committing changes to a different branch (after switching):

  1. Switch to the branch you want to commit to: Use the git checkout <branch_name> command to switch to the desired branch.
  2. Follow steps 1 and 2 from Scenario 1: Stage your changes and write a commit message.
  3. Commit your changes: Similar to Scenario 1, Git will create a snapshot of your project with those changes specifically for the branch you switched to.

Remember: Branching creates a copy of your project, so commits made on one branch won’t automatically appear on others. You’ll need to switch branches and commit specifically to the one you want the changes in.

Merging branches is like combining two different versions of your project into one. Imagine you and a friend are working on separate copies of a grocery list for a party. Merging lets you take the best of both worlds and put it all together.

Here’s a simplified breakdown of how to merge branches:

  1. Switch to the Main Branch: This is usually the branch where you want to keep the final, merged version of your project.
  2. Merge the Other Branch: Use a command like git merge branch_name (replace branch_name with the actual name of the branch you want to merge).
  3. Resolve Conflicts (if any): Sometimes, both branches might have edits to the same file. The tool will highlight these conflicts, and you’ll need to decide which changes to keep. Think of it like finding common ground between your grocery list and your friend’s.
  4. Commit the Merge: Once everything is sorted, create a new “commit” to save the merged version of your project.

That’s the gist! Merging helps you integrate different development paths and keep your project moving forward.

Important Note: This is a simplified explanation. In reality, there might be additional steps or considerations depending on the complexity of your project and your version control system.

How to make Markdown ?

How to format text ?

GitHub uses a special kind of writing style called Markdown to format text. It’s pretty easy to learn, kind of like using emojis in a text message. Here’s a quick guide to get you started:

  • Bold & Italics: Want to make something stand out? Surround your text with asterisks (*) for bold and underscores (_) for italics.

  • Headings: Create titles for your sections using hash symbols (#). More hashes (#) make smaller headings.

  • Bullet Points: Starting a line with an asterisk (*) or hyphen (-) will automatically create a bulleted list.

  • Numbered Lists: Use numbers followed by a period (1.) to create numbered lists.

  • Code Blocks: Working with code? Wrap your code snippet in three backticks (“`) to format it properly.

There’s more to Markdown, but this gives you the basics for making your text on GitHub clear and easy to read. For more options, you can search online for “Markdown guide”.

Here’s how to format headers on GitHub using Markdown, which is a way to write code and format text easily:

1. Hashtags for Hierarchy (#):

Imagine headers like headings in a book. To make a header, use the hash symbol (#) followed by your title. The more hashtags you use (up to six), the smaller the heading text will appear.

  • One hash (#) creates the biggest and main heading.
  • Two hashtags (##) create a sub-heading, slightly smaller than the main one.
  • Three hashtags (#୩#) create an even smaller sub-heading, and so on.

2. Keep it Clear and Simple:

Use clear and concise language in your headers so people can easily understand the structure of your content.

3. Automatic Table of Contents (Bonus!):

If you use two or more headings with different levels (like # and ##), GitHub automatically creates a handy table of contents at the top of your file. This makes it easy for people to navigate your content.

So, formatting headers with hashtags is a quick and easy way to organize your text on GitHub!

There are actually two ways to interpret “make a list on GitHub”:

1. Creating a checklist within an Issue or Pull Request:

Imagine you’re working on a project with a friend on GitHub and need a to-do list. Here’s how to create a checklist:

  • Open the Issue or Pull Request where you want the list.
  • Click the pencil icon to edit the description.
  • Start each to-do item with a hyphen (-) followed by a space and then brackets []. For example:
    • [ ] Buy ingredients
    • [ ] Bake the cake
    • [ ] Decorate!
  • As you complete each item, click the empty brackets to turn them into checkmarks [x].

2. Creating a list as a Markdown file (for curating resources):

This is useful if you want to share a list of interesting resources, like awesome libraries or tutorials. Here’s the process:

  • Create a new file in your repository with a .md extension (e.g., awesome_resources.md).
  • Use Markdown syntax to format your list. You can use:
    • Asterisks (*) for unordered lists:
      • Resource 1
      • Resource 2
    • Numbers (1.) for ordered lists:
      1. Resource 1
      2. Resource 2
  • Commit and push the changes to your repository.

Remember, this second option won’t have automatic checkboxes, but it’s a great way to share curated lists with others.

Adding links in GitHub is pretty straightforward, like inserting a link in a text message. Here’s how to do it:

1. Prepare your Text and Link:

  • Write the text you want people to click on (like “Click here for the guide”).
  • Copy the web address (URL) of the page you want to link to.

2. Use Square Brackets and Round Brackets:

  • Put the text you want to be clickable inside square brackets [].
  • Right after the square brackets, add the URL in round brackets ().

For example, if you want your text to say “Click here for the guide” and link to https://git-scm.com/book/en/v2/Getting-Started-Installing-Git, you would write:

Click here for the guide(https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)

3. Easy Way – Use Keyboard Shortcut (Optional):

  • If you’re editing text on GitHub, some platforms let you use a shortcut.
  • Highlight the text you want to link.
  • Press Command + K (or similar shortcut depending on the platform).
  • Paste the URL in the pop-up window and hit enter.

That’s all! Now your text will be clickable, taking users to the linked webpage.

There are two main ways to add images to your GitHub project:

1. Linking to an image hosted elsewhere:

  • This is like finding a cool picture online and showing it to your friend by sending them the link.
  • Find a reliable image hosting service (like Imgur) and upload your image there.
  • Copy the image URL (the web address).
  • Use Markdown syntax to display the image in your GitHub file (like README). Markdown is a simple coding language used for formatting text on GitHub. Here’s the basic structure:
!["alt text"](image URL)
  • Replace “alt text” with a short description of the image (helps accessibility).

2. Uploading the image to your GitHub repository (not recommended):

  • This is like putting the picture directly into your friend’s project folder. Not recommended as it can bloat the repository (make it too big).
    • Not ideal for large images or many images.
    • Place the image file in your project folder.
    • Commit and push the changes to GitHub.
    • Use Markdown syntax similar to above, but use the file path instead of a URL.

In short, linking to an external image is generally the better option!

How your Github Looks as a working professional as well as college Students ?
What points should be add in Github Portfolio ?

Your GitHub portfolio is like your online resume for the tech world, so you want to impress potential employers or collaborators! Here are some key things to include:

  • Show off your best projects: Pick projects that highlight your skills and interests. These can be personal projects, schoolwork, or even contributions to open-source software (made by many people).
  • Readme for the win: A readme file is like a welcome sign for your project. Write a clear and concise readme that explains what the project is about, how to set it up, and how to use it.
  • Keep it clean and tidy: Your code should be well-formatted and easy to read. This shows attention to detail and good coding practices.
  • Collaborate and contribute: Contributing to open-source projects is a great way to show you can work with others and learn new technologies.
  • Make it visually appealing: If your project has a user interface, consider adding screenshots or a short demo to showcase it.

By following these tips, you can create a GitHub portfolio that effectively highlights your skills and makes a great first impression!

There isn’t actually a way to directly insert achievements onto your GitHub profile. GitHub awards achievements based on your activity on the platform, and they automatically appear on your profile if enabled.

Here’s the breakdown:

  1. Earn Achievements: By using GitHub in various ways, you’ll unlock achievements. This could involve things like creating a repository, submitting a pull request, or getting stars on your project.

  2. See Your Achievements: These will automatically show up on your profile if you have them enabled.

  3. Enabling Achievements (Optional): By default, achievements are visible on your profile. But if you want to hide them, you can follow these steps:

    • Go to your profile settings on GitHub.
    • Look for the option “Show Achievements on my profile”.
    • Uncheck the box if you want to hide them.

So, instead of inserting achievements, you focus on using GitHub and unlocking them naturally! They’re a fun way to show off your GitHub activity.

GitHub itself doesn’t have a built-in system for showing coding achievements like points or badges. But there are a few ways to showcase your coding skills and contributions:

  1. Profile README: This is like a mini-billboard on your profile page. You can write about your coding experience, the languages you’re strong in, and even link to interesting projects you’ve worked on.

  2. Contributions Graph: This cool graph shows your activity on GitHub over time. Consistent contributions demonstrate your dedication and coding habits.

  3. Public Repositories: Having public repositories where you’ve written clean and well-documented code is a great way to show your skills.

  4. Open Source Contributions: Contributing to open-source projects lets you collaborate with other developers and showcase your problem-solving abilities.

  5. Starred Repositories: Look for high-quality, well-maintained repositories and star them. This shows you have good taste in code and are engaged with the developer community.

By focusing on these aspects, you can create a strong GitHub profile that highlights your coding achievements!

Your GitHub profile can be like a supercharged resume for tech jobs, especially if you don’t have a ton of professional experience yet. Here’s how to use it to impress potential employers:

  • Polish your profile: Make sure your profile information is clear and up-to-date. Write a bio that highlights your skills and interests.

  • Pick the right projects: Show off your best work! Include projects that are relevant to the jobs you’re applying for.

  • Spruce up your projects: Give your projects descriptive titles and clear explanations (like a mini-resume for each project).

  • Make it pretty: Add screenshots or visuals to make your projects look inviting.

  • Link it up: Include a link to your GitHub profile right on your resume, usually in the header section with your contact information.

By using your GitHub profile this way, you’re giving employers a chance to see your coding skills and work style firsthand. It’s like showing them your portfolio, but for code!

Leave a Comment