I have to create 100 repos from my local filesystem. Each project directory has to be created as a separate repo.
I have created separate folders for each of my project and created a base repo on Github. I clone it to my local and tried to do push. However I got all these folders as folder on GitHub.
I need each folder to be a new repo.
Your script it such as, for each folder:
you call the GitHub API to create a new repository
you initialize a new empty repository in the current folder
git init .
git add .
git commit -m "first commit for folder x"`
you define the remote URL, and push
git remote add origin https://github.com/you/folderN
git push -u origin master
Related
Here is what im try to achieve, I have a laravel app with a BitBucket repo in my laravel project public directory (public/repo.name).
Now what i want is to run, git add . git commit -m "Changes" and git push from my (public/repo.name) directory inside my laravel app.
I want the git commands to run when i go to lets say, http://127.0.0.1:8000/deploy this would only deploy whatever changes are in (public/repo.name)
Convert your Project to a Git Project
Open your terminal and navigate to the project root directory and run the git init command.
git init
git-init-laravel-project
Git init Laravel project
Git Add and Commit All Files
With the git init command we have successfully converted our project into a local git project. Although we have not yet added a git remote to our project.
As a second step lets go ahead and add and commit all the files to our local git repository.
Run the git add and git commit command on the project root.
git add .
git commit -m "First Commit"
The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit.
The git commit command commits the staged snapshot to the project history. Committed snapshots can be thought of as “safe” versions of a project—Git will never change them unless you explicitly ask it to.
Git add and Git commit on Laravel project
Create a New BitBucket Repository
We are now ready to push our changes to a remote repository. But before that we have to create a repository where we can push our changes.
Login to Bitbucket if you already have an account or SignUp for a new account. On the left hand menu , Click on the + symbol to get the option of Creating a New Repository.
Create Bitbucket empty Repo for Laravel.
Enter a suitable project name and click on Create Repository. A blank repository will be created and you will be redirected to the overview page of the repo.
Now we can go ahead and make this repo our remote repo for the Laravel project.
Add Remote Repo and Push Changes
To add the repository you just created as the remote repo for your local Laravel project. Run the following command on your project root in terminal.
git remote add origin https://<repo_owner>#bitbucket.org/<accountname>/<reponame>.git
Replace the repo_owner and accountname in the URL accordingly.
git-laravel-remote-add
git remote add laravel
Now we can go ahead and push the changes to remote repository.
git push -u origin master
git-laravel-push-bitbucket
Git push Laravel project
If you see at source in your bitbucket repository. You should see your Laravel directory structure along with the files.
I want to create a new empty repository with git. I cannot find a simple solution online that explains this step.
This documentation states "git-init - Create an empty Git repository or reinitialize an existing one" but then doesn't say which options are needed to make it empty:
https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-init.html
Is a --bare repository the same as an empty repository?
Problem:
I have two different projects with different repo's on github, but when I try to use Git (in Bash) after changing the directory to the new project, it keeps pushing with files from the old project.
I think the problem is that git is using the old repo files and thinks the new folder is just additional files perhaps? Basically I want to start from fresh. Can I just start from scratch on my new project with a new repo?
I have tried $ git init in a new directory, but then it just says: "Reinitialized existing Git repository in /home/user/new_project/.git/"
I tried: $ git remote set-url origin git#github.com:User/New_Project.git
but that just updates where it pushes my new project to, and then includes old projects files.
Please help a noob trying to figure things out the hard way 🙏🏼
Delete .git folder:
rm -rf .git
Then create new git repository:
git init
git remote add origin <remote-URL>
git add .
git commit -m "new clean repo"
git push --force origin master
create 1st project
make git init
create a remote repo for 1st project
link remote repo to 1st project
create 2nd project
make git init
create a remote repo for 2nd project
link remote repo to 2nd project
Git will push everything to its proper remote repo
Small hint from my side
git init : create empty repository and reinitialize an existing one
following link will give more information about different options can be used during git init ($GIT_DIR)
https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-init.html
To deploy my Laravel app to my server, I decided to just download the zip file and unzip it in the folder.
However, I made some changes on my server and I would like to push them to GitHub.
Since there is no .git folder, I don't get how am I supposed to commit the changes or pull from the repository.
Can you help me ?
If you have a repo already that has commits do:
git clone git#REPO_LOCATION_INFO
Check out a new branch on your local:
git checkout -b branch-name
Make your changes, save, add, commit, and push them:
git add .
git commit -m "My commit message"
git push origin branch-name
then open a pull/merge request in your repository and merge to master.
Otherwise you can remote the folder on your local to your repository with:
git remote add origin git#github.com:user/repo_name
and then commit like shown above.
Hope this helps!
I've successfully done that following way:
Rename repo zip downloaded (without .git)
mv repo repo-bak
Clone original repo
git clone <url>
move .git file to zip downloaded repo
mv repo/.git repo-bak
delete cloned repo
rm -rf repo
change the name back to the original
mv repo-bak repo
add, commit and do whatever you want
cd repo && git status
I am new in git and want to push some java files to remote github repository. The files are NOT a project, just some algorithm problems that I want to share on github.
When I tried git push the alert fatal: not a git repository: .git
Is there any quick way to push some/single file to repo using git bash? thanks
One solution would be to do a git init . in the folder whare your files are.
Then add the github repo as a remote:
git remote add origin https://<yourLogin>#github.com/<yourLogin>/<yourRepo>
git add .
git commit -m "My first files"
git push -u origin master
The other approach, especially if the remote repo on GitHub is not empty (because of README and LICENSE files), is to clone that repo:
git clone https://github.com/<yourLogin>/<yourRepo>
cd <yourRepo>
# copy your files there
git add .
git commit -m "My first files"
git push -u origin master
so I just installed a new remote git repository on one of our servers and want to move our old projects there. Our existing projects have local git repositories, and we can add repos from the server, but how do we move our existing projects onto the server?
Any ideas?
You would do these steps:
Make the individual repositories on the server.
git clone --bare nameofrepo
On the actual repo, add the remote to the repository from which you want to send up work:
git remote add origin <url to your remote>
Now push your branch for your work:
git push origin master
Repeat for any other branches you want to have pushed to the central repo.
The URL in the first command can also be a regular file path. Most solutions, however are through an SSH connection.
After creating your Xcode project, cd to that directory
and make sure you are on the master branch
Type:
git remote add origin <URL-of-your-GitHub-repository>
git pull
git branch --set-upstream-to=origin/master master
git merge
git commit -m "Merging with remote”
git push
Now your new project has been pushed to the remote GitHub directory.