The Git command is written and compiled briefly as the following command.
When we initialize, the subdirectory structure for git in the folder is created.
Looking at the Situation
Looking at the state of our repository is often something we have to do. We give information about the repo and we understand what to do depending on the situation.
Copying a repository is one of the simplest procedures. The only condition is that the destination folder does not exist or is an empty folder. (some users delete the contents, even if they are folders, etc. This is a separate issue, but we will talk through Git SCM)
git clone repository_url [folder_name]
As a repository URL, for example, when you enter a repository in
Github, we will use the link that appears under the button Clone or Download:
It is not compulsory to write the name of a folder, but it will help you to learn.
git clone firstname.lastname@example.org:techsoftcenter/query_builder.git qb
this way. You may receive an error if you have not set the SSH Key.
Adding Files to Repository
Adding and committing files is two separate cases, and even uploading up (to the server) is a separate process. If we need to follow this step by step, we need to do this in order to add, commit and upload files.
We can also use the add command to add files to the repository.
// repository from root;
speak add filename add filename.extension
git add folder / path / filename.extension
While we are in the root directory of our repository, we can add it as follows:
// We will move from the root directory.
go add logo.png
git add layout.js
git add npm.js
By adding, we make changes, added, deleted files, etc. We have prepared for our commit. Now it’s time for us to commit. Commit to process our process. So; I added this file, I deleted this file, we call it updated.
While commit, we also need to write a message, the reason we write it is not necessary to know what we have added to delete what we do not need to write very unnecessary notes so that the commit can be seen what has changed. For example; # 123. bug fixed we can write. Here we added a file to be considered, we do not need to write a long message such as file b deleted, you can examine here for example. Since only 1 file has been modified in the commit detail in the example, you can only see the changes of that file, but by looking at the different reports, we can see what commit is done.
git commit -m 'we're writing your message here'
Above we have made a single-line example.
-m can write our message directly. Alternatively, we could write our message like vim by saying
git commit directly and write down the change in detail.
Push Commit (s)
This is a step we also call pushing, throwing up. We have edited and deleted files, as well as throwing changes into the main repository.
git push [remote_name] [branch_name]
git push origin master
Getting the Current Report from Remote Repo
To get the latest update from the remote repository, we will first perform fetch, then pull.
Fetch brings us only the status of the last updated version. So this has changed, we see reports like this has changed. We will also use the pull command to get the changes.
git fetch [remote_name]
git fetch origin
If we have not given any name, the default name is given to our file as
Pull means pull. We’ve received the changes, now we can take our file. If you pull without fetch, you pull the last version of the fetch.
git pull [remote_name] [branch_name]
git fetch origin
git pull origin master
I hope it has been a useful article.