Git Javascript AJAX jQuery HTML PHP Example MORE

How to push(commit) the code in the repository


There is two scenario

We have repository which contains files and folders and now create our own files and folders and push into repo.

First Case

We use the following command.

  1. git clone : Run only once(at first time)( enter username and password(token))
  2. git checkout < branch name >
  3. git pull ( enter username and password(token))
  4. Make changes in our file and folder

git add . (. for all files and folder) or git add < file name >

git commit -m "message"

git push ( enter username and password(token))

Second Case

for first time when repo is empty

  1. open terminal at our root folder

git init

git add . or git add < file name >

git commit -m "message"

git branch -M main

git remote add origin < repo http url >

git push -u origin main

once it's successfully pushed after that we can create branch and commit our latest code

git add . or git add < file name >

git commit -m "message"

git push

store password

https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git