Getting master instead of main - github

When I use create-react-app and cd into the directory it already shows me (master) when I haven't even initialized git. When I try to do git init and set remote origin it still stays the same and my repository isn't connected. What should I do?

Create react app initialises git automatically, and adds a .gitignore

Try to solve it by this example
echo "# qqq" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin git#github.com:{username}/{repository}.git
git push -u origin main

Related

Git push creates my project folder inside another folder, how to avoid it?

I have been creating some repositories of my projects since the terminal and everything was good, but recently I tried to push a project to GitHub and but another folders are created.
For example, the path of my project folder is /Desktop/Programming_course/React_Native/robotreact.
So, since the terminal I go to the path of my Project robotreact and I run:
git add .
git commit -m "first commit"
Then, in GitHub, I create my repository and after that I run:
git remote add origin https://github.com/Josesosa0777/robotreact.git
when I push it running: git push -u origin main
In my GitHub are created other folders:
How can I avoid those extra folders?
It seems like if another project is added, I am not sure if the problem is about a SSH key, I dont know how to solve it, any idea?
That means you have initialized your Git repository in / instead of /Desktop/Programming_course/React_Native/robotreact: check for /.git
If that is the case, and you don't have many commits, you can simply:
delete /.git
initialize the repository in the right folder,
add the remote origin
add files, commit and push
That is:
cd /Desktop/Programming_course/React_Native/robotreact
git init .
git remote add origin https://github.com/Josesosa0777/robotreact.git
# check your user.name/user.email
git config user.name
git config user.email
git add .
git commit -m "First import"
git push -u origin main
If your local branch is master:
git push -u origin master:main

How to update code in gitlab

My team committed code to gitlab repository and I need to take those updates. I already clone the project into my local directory but didn't take update before.
For taking update what commands need to run. I already tried pull command and it shows the changed file details but that changes are not applying to the project. For apply the changes any new command needs to run again?
Run following commands for taking the update:
git fetch && git checkout master
git pull
git config --global user.name "demo"
git config --global user.email "demo#gmail.com"
Create a new repository:
git clone https://gitlab.com/demo_test.git
cd demo_test
git switch -c main
touch README.md
git add README.md
git commit -m "add README"
git push -u origin main
Push an existing folder:
cd existing_folder
git init --initial-branch=main
git remote add origin https://gitlab.com/demo_test.git
git add .
git commit -m "Initial commit"
git push -u origin main
Push an existing Git repository:
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/demo_test.git
git push -u origin --all
git push -u origin --tags

git push origin master creating empty directories in github

I have cloned certain github repositories to my laptop. Now I want to push these local directories to my github .When I do "git push origin master" everything does smoothly. But if I have a look at my github repository I can only see empty directories getting created. All the directories are under the same directory .
The commands that I perform to update on github :
git add .
git commit -m ""
git push origin master
Following is a snapshot of my github view :
i think you havent added new files to repository
1. git status
2. git add -A
3. git commit -am "your commit"
4. git push origin master
try these i believe this will help yo
I did the following and it worked :
git rm --cached Retrofit2SampleApp
git rm --cached ud851-Sunshine
rm -rf Retrofit2SampleApp/.git
rm -rf ud851-Sunshine/.git
git add Retrofit2SampleApp
git add ud851-Sunshine
git commit -m "commit after removing cache and .git inside the folders"
git push origin master
Got some clue from the following link :
Git - how to track untracked content?

Github - How to update my own repository?

I have a repository in my Github, and I cloned it on my desktop. Then I did some work in the folder. How do I commit those changes to my repository?
below code is right, but don't forget to add remote address to key "origin".
git remote add origin <YOUR_REPOSITORY_PATH>
git add .
git commit -m 'some change'
git push -u origin master
-u – sets repo branch as defaults, so then you can push, just git push
May
git add .
git commit -m "my changes"
git push origin master

how to code commit on github using MINGW32?

i created a repositories on github.
now i want to put my some code there can anybody tell me how to do this and how to commit code.
i tried using this lines
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/Dany001/myrepo.git
git push -u origin master
please short out my problem
Thanks