Git Create Operations
Create New User
Now login from git on server before doing the next setup
Create a Bare Repository
Let us initialize a new repository by using init command followed by –bare option. It initializes the repository without a working directory. By convention, the bare repository must be named as .git.
cd /home/git mkdir project.git cd project.git/ git --bare init
Push Changes to the Repository from client or local machine
We have created a bare repository on the server and allowed access for two users. From now on, Tom and Jerry can push their changes to the repository by adding it as a remote.
Git init command creates .git directory to store metadata about the repository every time it reads the configuration from the .git/config file.
Tom creates a new directory, adds README file, and commits his change as initial commit. After commit, he verifies the commit message by running the git log command.
git init echo 'TODO: Add contents for README' > README git status -s git add . git status -s it commit -m 'Initial commit'
Tom committed his changes to the local repository. Now, it’s time to push the changes to the remote repository. But before that, we have to add the repository as a remote, this is a one-time operation. After this, he can safely push the changes to the remote repository.
Note − By default, Git pushes only to matching branches: For every branch that exists on the local side, the remote side is updated if a branch with the same name already exists there. In our tutorials, every time we push changes to the origin master branch, use appropriate branch name according to your requirement.
git remote add origin gituser@public-ip:project.git
git push origin master