Git Basic Concepts

In this workshop we are going to talk about git and how that tool help us to develop software collaboratively, and keep our code safe when we are working with others.

DELIVERABLE

At the end of this workshop you have to present a report on the README file in which you show the execution of each step presented as follows

The Report has to be presented on Github in the repository that you are going to create when the workshop has been finished. Don´t forget to include the code too.

Setup

Download git using the following urls

Creating a local repository

Git init

Let's code

Two strings, and , are called anagrams if they contain all the same characters in the same frequencies. For example, the anagrams of CAT are CAT, ACT, TAC, TCA, ATC, and CTA.

Complete the function in the editor. If and are case-insensitive anagrams, print "Anagrams"; otherwise, print "Not Anagrams" instead.

Input Format

The first line contains a string denoting . The second line contains a string denoting .

Constraints

    • Strings and consist of English alphabetic characters.

  • The comparison should NOT be case sensitive.

Output Format

Print "Anagrams" if and are case-insensitive anagrams of each other; otherwise, print "Not Anagrams" instead.

Sample Input 0

anagram
margana

Sample Output 0

Anagrams

Explanation 0

The two strings contain all the same letters in the same frequencies, so we print "Anagrams".

Sample Input 1

anagramm
marganaa

Sample Output 1

Not Anagrams

Explanation 1

The two strings don't contain the same number of a's and m's, so we print "Not Anagrams".

Sample Input 2

Hello
hello

Sample Output 2

Anagrams

Explanation 2

The two strings contain all the same letters in the same frequencies, so we print "Anagrams".

Taken from: https://www.hackerrank.com/challenges/java-anagrams/problem

Preserving our changes

Use the following command

git add .

Answer: What is the purpose of this command?

Use the command line to type the command showed below

git commit -m "Message"

Answer : Why we used it?

Now we have our code in our local git repository, but it is not present in any remote repository that can be accessed by our teammates

Using Github

Go to github

If you do not have a github account create it, cause you are going to need it.

Create a new repository on github and name it workshop1

Copy the url of your remote repository, in order to link it with our local repository that was created previously

Use the following command to link the remote repository with the local one.

git remote add origin <server>

Using the push command

Using the command line, type the command below

git push origin master

Answer: What is the purpose of the this command?

Cloning our repository

In other folder or machine use the following command in order to clone the remote repository created above.

git clone <repository>

Answer: What is the purpose of this command?

Let's code

The challenge here is to read n lines of input until you reach EOF, then number and print all lines of content.

Hint: Java's Scanner.hasNext() method is helpful for this problem.

Input Format

Read some unknown n lines of input from stdin(System.in) until you reach EOF; each line of input contains a non-empty String.

Output Format

For each line, print the line number, followed by a single space, and then the line content received as input.

Sample Input

Hello world
I am a file
Read me until end-of-file.

Sample Output

1 Hello world
2 I am a file
3 Read me until end-of-file.

taken from https://www.hackerrank.com/challenges/java-end-of-file/problem

Preserve the changes using your partner's github account.

Take a screenshot of the commit report in the github account and include it in the report

Using pull command

Use the first github account to type this command

git pull origin master

Answer: What that command does?

Include the report on github repository using the commands you have learned

If you want more information about git you can find it at http://rogerdudler.github.io/git-guide/

Last updated