Typically, the Git directory is called (Repository). In short, it is called (Repo). Here we are going to learn the setup of a git repository. The flow is first we have to git Initialize our project. Then need to add project files to the storage area and finally commit the changes. It creates a version with each commit.
Flow of Git Setup |
If we have already a project and now we want to add it to git. Then follow the simple bellow steps.
Step 1: Open Git Bash from our window or go to your project directory, right click and then click on 'Git Bash Here'. Now initialize our git project. Here is our Git project name is Project-Test. This project has only a text file (Employee.txt).
Initialize command -
git init
Git has been initialized in this project. |
Step 2: Check the current status of your repository. It's just initialized the repo. So there is no branch master and commit yet.
Status Check Command -
git status
Important, Here the file Employee.txt is untracked now. So, we have to add our project file to the storage area.
Step 3: Add to the storage area and check again the status.
Command -
git add Employee.txtgit status
Now Employee.txt file added to the storage area. But still, it wont create a version until we commit.
Important - If we want to add all files of project to the storage area, use the below command.
git add --allorgit add
Step 4: Final commit with a comment. Provide comments to identify all commit.
Command -
git commit -m "My comment - First Commit"
Now it created a version with this commit.
Current data. Just Name. |
Done...😀
In the next tutorial, we will change the Employee.txt data and commit again. And then get the earlier version from the commit log.
[Push to GitHub : git push -u origin master]
0 Comments