Wanted to add a new project to Git/GitHub/GitLab ? Here we go…
Right click on the project folder -> Git Bash Here
Call the below command:
git init
It will initialize it to be a git project, you can see a .git hidden folder created in the same folder.
You can see the same folder will become the master.
After every command you execute you can check the status of the current working directory tree by calling below comand:
git status
So currently this code is in the “Working Directory” stage.
Once you do the git add, it will move the code to the “Staging Area” stage.
Then if you do the git commit, it will move to “Local Repository” stage.
And finally when you do “git push“, it will move to “Remote Repository” stage.
So, lets proceed with the further steps.
Add all files to the Staging area:
git add --all
Lets move the files to local repository:
git commit --m "some message"
Lets move the files to remote repository:
git push <remote url> <branch>
How to commit/push your changes to git ?
Suppose you did some modifications in some files and you want to push those changes. Then first you want to see how many files had been changed by:
git status
You will see changed file in Red color.
Unlike SVN, which is a centralized version control system, Git is a distributed version control system. It has different stages of file movement. Below is the flow of stages when someone has to move his changes to the final repository:
Staging -> Local repository -> Remote repository
So now you have to add those file to the Staging by:
git add --all
If you check the status now you will see those changed files in Green color.
Then you need to commit it to the local repository by:
git commit --m "some message"
Then if you check the status, you will see all the working tree is clean, nothing to commit.
Then you need to push the changes to remote repository by:
git push