Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I want to write a small Python dummy project:
print('Hello world.')
... in a file called hello.py.
Next: I want to make this a small dummy project at github.
After creating a virtual-env (via PyCharm) I have these directories:
./foo
./foo/venv
./foo/venv/lib
./foo/venv/lib/python3.6
./foo/venv/lib/python3.6/site-packages
./foo/venv/include
./foo/venv/bin
I want to store my small project in git and upload it to github later.
Are there (official) docs how to start a new project after creating the virtualenv?
If I understand your question correctly, I believe this is what you are looking for:
How to create a repository in github:
In the upper-right corner of any page, click , and then click New
repository.
In the Owner drop-down, select the account you wish to create the
repository on.
Type a name for your repository, and an optional description.
Choose to make the repository either public or private. Public
repositories are visible to the public, while private repositories
are only accessible to you, and people you share them with. For more
information, see "Setting repository visibility."
When you're finished, click Create repository.
Creating a repo
Adding an existing project to a repo:
Open Terminal.
Change the current working directory to your local project.
Initialize the local directory as a Git repository.
$ git init
Add the files in your new local repository. This stages them for the
first commit.
$ git add .
Adds the files in the local repository and stages them for commit.
Commit the files that you've staged in your local repository.
$ git commit -m "First commit"
Commits the tracked changes and prepares them to be pushed to a remote repository.
In Terminal, add the URL for the remote repository where your local
repository will be pushed.
$ git remote add origin remote "repositoryURLgoesHere"
Sets the new remote
$ git remote -v
Verifies the new remote URL
Adding a project to the repo
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
Improve this question
I am trying to copy .git folder of private repo of any user when access token is provided using python. However, I could not be able to download it. I found bash script to download the file but I wanted to retrieve only .git folders. This is what I was trying
python script
TOKEN = "tokensoicanaccessprivaterepo"
OWNER=""
REPO=""
API_URL=f"https://api.github.com/repos/{OWNER}/{REPO}?access_token={TOKEN}"
req_json = requests.get(API_URL).json()
# git_url = req_json['ssh_url']
# git clone https://${TOKEN}:x-oauth-basic#github.com/{OWNER}/{REPO}.git
os.system(f"git clone https://${TOKEN}#github.com/{OWNER}/{REPO}.git")
the way I am doing asks for password event after providing personal access token with repo and user scope while cloning.
I have looked into various resources but I did not find the way to copy '.git' folder of private repo of any user with the github provider token.
UPDATE
scope
In order to make a clone without working directory, use --bare:
git clone --bare https://{TOKEN}:x-oauth-basic#github.com/{OWNER}/{REPO}.git
Also, as pointed out by you in the comments:
there is a simple typo in the command which I could not notice. There should not be $ before {TOKEN} as I am using f string.
And finally, ensure that your access token has the repo scope.
This question already has answers here:
How do I find and restore a deleted file in a Git repository?
(30 answers)
Closed 1 year ago.
I used git rm -r virtualenv to remove my virtual environment from git, not realizing it would delete it locally too. I do still have the this virtenv folder still in my remote Github repository. What commands do I need to run to get it back into my local directory? The project structure was an outer Flask directory for backend files, and inner React directory for frontend, so I have two virtualenv folders to get back.
1- Take everything from git. Git fetch basically downloads everything from the git repo but does not merge anything into your local branch. It just makes sure that you have everything on your computer
git fetch --all
2 - Check out the file or directory you wish. This takes the folder then into your local branch
git checkout origin/<branch_name> <path_to_directory>
3 - Then you can just commit it and push. In your case, it is probably not required but if you were on another branch. You would need these steps. (For example: when you take the original version of a file from master and want to push it to your local branch
git commit -m "..."
git push origin <branch_name>
For automating some of our workflows I am implementing some Python scripts which create project templates. The content of a project template is located in a folder which also is a local git repository. So the project in the end will be linked and pushed to a remote repository on our company server. Each project additionally uses some of our own created libraries which are added as a git submodule into the project folder and is part of the project git repository.
So my script should now first create the local project git repository which I do by using Gitpython with the following code:
Repo.init(os.path.join(sRepoPath, '.git'), bare=True)
After the repository is created, I want to add one or more remote repositories as a submodule and then clone them into the project folder. But I can't find out how to do it from the Gitpython documentation. It does not cover such a case with remotes as a submodule.
I've already tried several code combinations from the Gitpython documentation. Something like (of course not working):
mainRepo = Repo(sDestinationRepoPath)
test_remote = mainRepo.create_remote('submodule', "ssh://git#bb.mycompany.corp:1234/fwlib/system_lib.git")
mainRepo.create_submodule(test_remote)
But I can't sort it out how it should be done. Can anyone tell me how to do it?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I am new to GitHub: I have uploaded a django project without a .gitignore file and GitHub Community banned my account.
That is why I need to know how to use a .gitignore file as well as adding a license.
Recreate your django project locally, initialize a new local git repository in init (git init .), and, before doing any git add/git commit, add:
your .gitignore (you can copy the Django one)
your LICENSE file (chose one of those)
Add and commit locally.
Then create a new GitHub account, a new empty GitHub repository.
Go back to your local repository and:
cd /path/to/local/repo
git remote add origin https://github.com/<NewAccount>/<newRepo>
git push -u origin master
You can then see "Where to store secret keys DJANGO" for managing your secret key.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I'm absolutely "brand new" to Paas and django/python.
I would install django on heroku.
Before, I need to install on it Python. But I'm unable to do that. I looked a while for doc about it, but unfortunately I'm not able.
I've created a heroku account. I log in and the try to follow the guide.
please, help me. give me some starting point...
TIA
Renato
Setting up your project
You'll need to add a couple of files to the root of your project:
The first file, named requirements.txt, should contain the dependencies for your project (this is not really Heroku specific). At the minimum, this should include:
Django
Then, you'll need to add a file named Profile (this is more Heroku-specific) that tells Heroku how you run your project:
web: gunicorn YOUR_PROJECT_NAME.wsgi:application
YOUR_PROJECT_NAME should be whatever argument you gave manage.py startproject. This should also be the name of the folder that contains your wsgi.py file (settings.py will be there too).
Deploying to Heroku
Next, you should initialize a git repository for your projec:t
git init
Then, commit your project:
git add .
git commit -m "Initial commit for my project"
Then, provided you installed the Heroku toolbelt, you should be able to add your application to Heroku:
heroku create
And finally, deploy to Heroku using git:
git push heroku master
You app isn't running yet, so you'll want to launch it:
heroku ps:scale web=1
Then, you can access it via your browser:
heroku open
You might want to have a look at Heroku's django guide.