ALX Git task solutions

Git Task Repo: Repo-Session

Create a new directory called 0x01-git in your alx-pre_course repo. Make sure you include a non empty README.md in your directory: at the root of your repository alx-pre_course AND in the directory 0x01-git And important part: Make sure your commit and push your code to Github – otherwise the Checker will always fail..

Solution

follow this codes step by step

cd alx-pre_course (enter)

mkdir 0x01-git (enter)

cd 0x01-git (enter)

echo “my second commit”>README.md (enter)

cd .. (enter)

git add . (enter)

git commit -m 'My second commit' (enter)

git push origin main (enter)

(Now check your code)

GIT task: Collaboration: be up to date

Of course, you can also work on the same branch as your co-workers and it’s best if you keep up to date with their changes. For this task – and only for this task – please update your file README.md in the main branch from GitHub.com. It’s the only time you are allowed to update and commit from GitHub interface. After you have done that, in your terminal: Get all changes of the main branch locally (i.e. your README.md file will be updated) Create a new file up_to_date at the root of your directory and in it, write the git command line used Add up_to_date to git, commit (message: “How to be up to date in git”), and push to the origin.

Solution

  1. Go to github.com, enter your alx-pre_course Repository

Double tap on 0x01-git

Click on the README.md file below and click on the edit button. Change the content and commit it

  1. Get all changes of the main branch locally (i.e. your README.md file will be updated)

Go to git bash, use the command

git pull (enter)

  1. Create a new file up_to_date at the root of your directory and in it, write the git command line used

echo “git pull”> up_to_date  (enter)

  1. Add up_to_date to git, commit (message: “How to be up to date in git”), and push to the origin

git status (enter) to check the status of your work

git add . (enter)

git status (enter) to check the status of your work if the previous works has been added.

git commit -m “How to be up to date in git” (enter)

git push

GIT task: Never push too much

Create a .gitignore file and define a rule to never push ~ files (generated by Emacs). Tips.

Solution

 ~/alx-pre_course (main)

$ cd 0x01-git (enter)

 ~/alx-pre_course/0x01-git (main)

$ echo “~”>.gitignore (enter)

 ~/alx-pre_course/0x01-git (main)

$ cat .gitignore (enter)

~

 ~/alx-pre_course/0x01-git (main)

$ git add . (enter)

 ~/alx-pre_course/0x01-git (main)

$ git commit -m “~” (enter)

 ~/alx-pre_course/0x01-git (main)

git push (enter)

Table of Contents

Collaboration is cool, but not really when you update the same file at the same time… To illustrate that, please merge the branch update_script to main: “Cool, all my changes will be now part of the main branch, ready to be deployed!” HHHHHHHAAAAAAAA CONFLICT (content): Merge conflict in bash/alx As you can see, you have conflicts between two branches on the same file. Your goal now is to resolve conflicts by using the version of the branch update_script, and push the result to the origin. At the end, you should have all your work from the branch update_script (new file and two updated files) and all latest main commits (new files, delete folder, etc.), without conflicts..

Solution

$ cd alx-pre_course

~/alx-pre_course (main)

$ git merge update-script

merge: update-script – not something we can merge

~/alx-pre_course (main)

$ git merge update_script

Already up to date.

~/alx-pre_course (main)

$ git commit –m  “Cool, all my changes will be now part of the main branch, ready to be deployed!”

bash: !”: event not found

~/alx-pre_course (main)

$ git commit -m  ‘Cool, all my changes will be now part of the main branch, ready to be deployed!’

On branch main

Your branch is up to date with ‘origin/main’.

nothing to commit, working tree clean

~/alx-pre_course (main)

$ git add .

 ~/alx-pre_course (main)

$ git push

Everything up-to-date

Social Media Auto Publish Powered By : XYZScripts.com