Posts

Showing posts from December, 2021

Git Challenge VII

Git Challenge VII   This challenge asks you to create a branch, make some modifications on that branch, and force Git to not perform a fast-forward merge. The high-level steps for this task are: 1. Ensure you’re on the `main` branch. 2. Create a branch named `contact-details`. 3. Switch to that branch. 4. Edit the README.md file and add the following text to the end of the file: "Contact: support@razeware.com". 5. Save your edits to the file. 6. Stage your changes. 7. Commit your changes with an appropriate commit message, such as "Adding README contact information". 8. Switch back to the `main` branch. 9. Pull up the graph of the repository, and don’t forget to use the `--all` option to see history of all branches. Make note of how `main` and `contact-details` look on this graph. 10. Merge in the changes from `contact-details`, using the `--no-ff` option. 11. Enter something appropriate in the merge message in Vim when prompted. Use the cheatsheet above to help yo

Git Challenge VI

  Git Challenge VI 1. Create a temporary branch with the name of **newBranch**. Solution -      git branch newBranch 2. Switch to that branch. Solution -      git checkout newBranch 3. Use the `touch` command to create an empty **README.md** file in the root directory of your project. Solution -      touch README.md 4. Add that new **README.md** file to the staging area. Solution -      git add README.md 5. Commit that change with an appropriate message. Solution -      git commit -m "Adding README.md" 6.Checkout the **main** branch. Solution -      git checkout main 7. Delete **newBranch** — but Git won’t let you delete this branch in its current state. Why? Solution First, try the following: -      git branch -d newBranch Git responds with: error: The branch 'newBranch' is not fully merged. If you are sure you want to delete it, run 'git branch -D newBranch'. 8. Follow the suggestion that Git gives you to see if you can delete this branch. Solution -      gi

Git Challenge V

  Git Challenge V Challenge 1: Show all the details of commits that mark items as “done” For this challenge, you need to find all of the commits where items have been ticked off as “done”; that is, ones that have an “x” inside the brackets, like so: `[x]` Solution You’ll need to search for the above string, and you’ll need to use an option to not only show the basic commit details but also show the contents of the changeset of the commit. To do this, use the search flag "-S" with git log, and also include the "-p" flag to see the contents of each commit: git log -p -S"[x]" Challenge 2: Find all the commits with messages that mention “streaming” You want to search through the commit **messages** to find where you or someone else has used the term “streaming” in the commit message itself, not necessarily in the content of the commit. Tip: What was that strangely named command you learned about earlier in this chapter? Solution Right, you want to use "

Git Challenge - IV

Git Challenge IV This challenge simply asks you to grab the contents of a file in GitHub and copy it into your global **.gitignore** with the following steps: 1. Navigate to [https://github.com/github/gitignore/tree/master/Global](https://github.com/github/gitignore/tree/master/Global). 2. Find the correct **.gitignore** for your own operating system. 3. Take the contents of that OS-specific **.gitignore**, and add it to your own global **.gitignore**. SOLUTION Here are the steps I followed to complete this challenge. You may have used slightly different methods to accomplish the same result, but here’s how I did it: - Navigate to [https://github.com/github/gitignore/tree/master/Global](https://github.com/github/gitignore/tree/master/Global) in a browser. - Click on the appropriate global .gitignore file for your operating system. I’m on a Mac, so I’ll use the macOS.gitignore file. - Copy the contents of this file and press Command + C (Control + C on a Windows machine) to copy it

Git Challenge - III

Git Challenge III This challenge simply reuses the commands you’ve used in this chapter to accomplish the following tasks: 1. Move the newly added **books/management_book_ideas.md** to the **website** directory with `git mv`. 2. You’ve changed your mind and don’t want **management_book_ideas.md** anymore, so remove that file completely. 3. But now you’re having second thoughts: maybe you _do_ have some good ideas about management. Restore that file to its original location in the **books** directory. Again, it’s worth your while to execute "git status" after each change, to see exactly what Git is going at each step. It’s a great way to get your bearings in your early days with Git. SOLUTION Here are the steps I followed to complete this challenge. You may have used slightly different methods to accomplish the same result, but here’s how I did it: - Move the file with "git mv books/management_book_ideas.md website/" - Next, if you try to do "git rm website/

Git Challenge - II

Git Challenge II This challenge simply reuses the commands you’ve used in this chapter to accomplish the following tasks: 1. Create a new file named **tutorials_ideas.md** inside the **tutorials** directory. 2. Add a heading to the file: `# Tutorial Ideas` 3. Populate the file with a few ideas, following the format of the other files, for example, `[ ] Mastering PalmOS`. 4. Save your changes. 5. Add those changes to the staging area. 6. Commit those staged changes with an appropriate message SOLUTION Here are the steps I followed to complete this challenge. You may have used slightly different methods to accomplish the same result, but here’s how I did it: - Create the new file with the command: touch tutorials/tutorial_ideas.md - Edit the files using nano, with the command: nano tutorials/tutorial_ideas.md - Added the following content to the file: # Tutorial Ideas Some tutorial ideas to help us branch out into new areas where no tutorial has gone before: [ ] Mastering PalmOS [

Git Challenge - I

Git Challenge I   The goal of this challenge is twofold: a. Create a fork of the ideas repository under your own user account on GitHub. ( https://github.com/raywenderlich/ideas ) b. Clone the forked repository to your local system. This involves a few steps: 1. Fork the **ideas** repository under your own personal user account. 2. Find the clone URL of your new, forked repository. 3. Clone the forked **ideas** repository to your local system. 4. Verify that the local clone created successfully. 5. Bonus: Prove that you’ve cloned the fork of your repo, and not the original repository. SOLUTION: Here are the steps to follow to complete this challenge: Forking the repository: - Log in to GitHub with your personal account. - Go to the ideas repository at https://www.github.com/raywenderlich/ideas. - Click the "Fork" button on the repository homepage. - Wait while GitHub creates a fork of the repository. - When the fork has been created, you’ll be taken to the new repository

Git Cheat Sheet

Following are the git challenges that you can practice using this cheat sheet. CHALLENGE 1: CHALLENGE 2: CHALLENGE 3: CHALLENGE 4: CHALLENGE 5: CHALLENGE 6: CHALLENGE 7: Remote Repository A remote repository is a collection of all the files related to a project, stored on servers elsewhere. Having a centralized repository makes it easier to share and contribute to a project. https://github.com/ifahimkhan/AndroidStorage.git Cloning Repository Creating a clone is exactly what it sounds like. A Git repository is simply a directory that contains all of the code and assets that you need to sync up. A Git repository is a repository that tracks all changes inside it. It uses a hidden .git directory to keep track of all the changes. git clone https://github.com/ifahimkhan/AndroidStorage.git Creating Branch git branch my-android To see Git created a new Branch or not  git branch  To switch between Branches, by default is main* git checkout my-android To delete a branch  git branch -d  my-andro