git push origin master creating empty directories in github - 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?

Related

Getting master instead of main

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

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

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 push and clone yii2 projects to github?

I have developed a simple web-app with yii2 and pushed it to my github repository. I tried to clone it to another folder and test it, but it didn't work.
Something tells me that it is because I get my yii2 from an archive without composer and when I try to clone it, I use composer install command to get vendor folder and autoload file and it doesn't do it right.
Why is it happening and how can I push my web-apps properly to github so that everyone can clone and start them? Thanks in advance.
Once you've done the Yii2 app ready into you local, kindly follow below basic commands of Git.
Git Basic Commands
Git Checkout:
$ git clone CHECKOUT_URL
To check git files status:
$ git status
To add all file into git:
$ git add *
To add selected file into git:
$ git add filename1, filename2
To commit all added/updated/deleted files into Git:
$ git commit -m "initial commit" *
To commit selected file into git
$ git commit -m "initial commit" filename1, folder1
To push committed files into Git master branch:
$ git push -u origin master
To see all exists branches:
$ git branch
To create new branch:
$ git branch changes
To select branch:
$ git checkout changes
To commit into selected branch “changes”:
$ git push origin changes
Other Git Commands:
$ git --help
usage: git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
[-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
[--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
[-c name=value] [--help]
<command> [<args>]
The most commonly used git commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
clone Clone a repository into a new directory
commit Record changes to the repository
diff Show changes between commits, commit and working tree, etc
fetch Download objects and refs from another repository
grep Print lines matching a pattern
init Create an empty git repository or reinitialize an existing one
log Show commit logs
merge Join two or more development histories together
mv Move or rename a file, a directory, or a symlink
pull Fetch from and merge with another repository or a local branch
push Update remote refs along with associated objects
rebase Forward-port local commits to the updated upstream head
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
show Show various types of objects
status Show the working tree status
tag Create, list, delete or verify a tag object signed with GPG