I want to use git as my cvs, to backup code and record the development process. First, use the following command to clone a project from remote server.
git clone git@127.0.0.1:/git/test.git
Before I push my own codes to the git server, I set the branch with following command.
git branch -m dev01
Of course if you want to use master as the branch, you could use “git branch -m master”, the default branch is “main”.
After I added the updated files, and commit it to my local git server by following command.
git add .
git commit -m "Hello World!"
Now I could try to pull my code to the remote server.
git push -u origin dev01
If I want to pull this origin to my master branch, execute the following command.
git pull origin dev01
Now I want to add my local project to remote git server.
# Init git information.
git init
# Set ignore files and directories, add node_modules in it.
vim .gitignore
# Add files to git stage
add .
# Commit git stage
comimt -m "First commit!"
# Add remote git address
git remote add origin git@192.168.0.100:/git/test.git
# Push local project to remote git server
git push -u origin master
If you want to change the remote url, use the following command.
// Show the current origin url.
git remote -v
// Modify the remote origin url.
git remote set-url origin git://192.168.0.100/test.git