Post

Learn With GitHub; Basics Of Repository Management

This article now will discussed for learn with, may did know with git but partially there is know with git. So i will share this article.

Repository basically is a warehouse to store all the files that we have.

Create New Repository

Log in to github, click on the “New Repository” to create a new repository, and fill in the requested information. Once the repository is created, which needs to be considered is the address given for the repository. For example, for me (which is in github username is slacker’s) to create a repository namely asb then the address to be given are: slacker’s/asb).

Open your konsole/terminal, create directory where the file to saved and go into directory. Example for create directoy with command:

  1. mkdir asb
  2. cd asb

Create this file README.md which will contain a brief description of this software:

1
2
3
```
touch README.md
```

Open this file and typing a brief description of this software. Initialize git in this directory

1
2
3
```
git init
```

Connect it to the repository directory we just created on github. Suppose for example repository above:

1
2
3
```
git remote add origin git@github.com:slacker's/asb.git
```

Description of these commands:

remote add = git command for add one copy from a github repository (because the server it is on server and away meaning is not local or remote).

origin = is name us which give for copying from this repository.

git@github.com = is command for opening git to github.com

slacker’s/asb = is address file from repository in github that we created earlier. The address is same with we created but just add .git in ending.

Add all files and subdirectory to us repository with command:

1
2
3
```
git add
```

commit, or commanded git for records all change that we created with run:

1
2
3
```
git commit -m "first commit"
```

Description of these commands: Commit = is git command for records all the changes. -m “first commit” = is message/comment that we want to relate with all the changes.

Send all that commited to github

1
2
3
```
git push origin master  
```

Description this command:
push = is git command to send (decline = push) the changes that we have  

previously marked with the commit command (see step 7) to github;
origin is the name of a copy of the repository in our machines; 

master is the name of the main branch of our code at github. All the main branch in github will be named master.

Send the changes to repository

If you has finished change of your code and already for send to server. Then do it following the commands:

1
2
3
4
5
```
git add  
git commit -m "Comments about changes done.  
git push origin master  
```

Note that if this command prompts for a password then this password for your account on Github. 
The first command (add) will examine all the code in the current directory (.) You and mark whichever has undergone a change; 
The second command (commit) will record any changes that occur Pade all files and ready to be sent to the server. Options -m “Comment neighbor changes made” a comment that will be associated with all of these changes; 
The third command (push) is the process of sending copies the changes from our repository (previously we give the name of origin) to the main branch on the server (which by default is named master).

Remove files/directory existing in the repository

If you will remove a files from repository that you do with following commands:

1
2
3
4
5
```
git rm files-name  
git commit -m "Comments about changes done"  
git push origin master
```

First command (rm) will remove files with file name;
Second command (commit) will avoid change a record;
Third command (push) is send process changing to server;

Change File name/directory which available in repository

- git mv old-name new-name

1
2
3
4
```
git commit -m "Comment about changing"  
git push origin master
```

First command (mv) will change file name or your old directory to new name;
Second command (commit) will avoid record a change
Third command (push) is sending process changing to server

Create copy from available repository

Example we want copying repository which has created in above to other directory such as otherrepo.
Open your terminal/konsole, create place directory we’ll store our repository and enter into a directory:

1
2
3
4
```
mkdir otherrepo  
cd otherrepo
```

git command for copy repository asb to this directory with running:

1
2
3
```
git clone git@github.com:slacker's/asb.git
```

Note that if this command prompts for a password, a password to access the SSH key that you created earlier (remember back in the installation process at this writing). The description of this command:

clone is git command for make copies from repository;
git@github.com: is command for open connection git to github.com
slacker’s/asb.git is address from repository which has we copying from github (this is same with address our repository but added a suffix .git)
. (dot) in command a suffix tag for process copying to this directory. Suppose we want to make copies in directory xyz then the command becomes:

- git clone git@github.com:slacker’s/asb.git xyz

Note about copies from this repository will give origin name

Attractive Changes of Repository So that you get the latest code that has been created by members of your team should take the following commands:

        git pull

     Alternative command is:
   
     git fetch      git merge origin

     The first command (fetch) are to take all the changes that occur on the server since the last fetch command;
     The second command (merge) incorporating the changes that happen to a copy of our repository (which by default will be named origin when we copy the repository with the command clone).

See the difference with the Repository
To see the difference between the former you have with that is currently stored on a server run the following command:

1
2
3
```
git diff
```
This post is licensed under CC BY 4.0 by the author.