To then create a new repository you need to first create a directory or folder for your project. In the command line with can be done using the mkdir command followed by the name of the folder you want to create:
$ cd
$ git init
This will create a new repository based on the folder you are currently in. A .git folder should appear in the directory. Note: .git will initially be hidden; you can use the ls -a command to show all hidden files in a directory.
This will mean you have a git repository for your project and can start making branches and tracking changes on files you’ve added using git add and git commit.
Create a repository in an existing folder
If instead you already have folder that you have created you can navigate to that directory:
This will mean you have a git repository for your project and can start making branches and tracking changes on files you’ve added using git add and git commit.
Create a repository in an existing folder
If instead you already have folder that you have created you can navigate to that directory:
$ cd
$ git init
$ git add .
$ git commit -m “Initial commit”
Connect to a remote repository
First you need to make a remote repository. To do this, we’ll use GitHub as an example, but other remote repository options like GitLab and BitBucket would work similarly. On GitHub, create a new empty repository. Give it a name and set whether you want to make it public or private. This should look something like this:
First you need to make a remote repository. To do this, we’ll use GitHub as an example, but other remote repository options like GitLab and BitBucket would work similarly. On GitHub, create a new empty repository. Give it a name and set whether you want to make it public or private. This should look something like this:
Log into your GitHub account and create a new repository by clicking the + icon in the upper-right corner of any page, then selecting New repository.
- Name the repository “MyProject”
- Add optional description
- Ensure repository is set to “Public”
- Click “Create repository”
After creating the “hello-world” repository, GitHub will display the repository main web-page on your browser. This page contains information required to link your GitHub repository, remote, to the repository you created with Git on your own computer.
You can then link your local repository to the remote one using the command:
$ git remote add origin <remote_url>
$ git remote -v
Which should print the remote URL that was specified.
When pushing your work to the new remote repository you need to then set up where exactly you want to push to. This can be done using the command:
$ git remote --set-upstream origin main
$ git push origin main
In the case of an older repository, where the default primary branch may be named master instead of main, the command would be:
$ git push origin master
After providing your github username and password, you will receive following message:
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Tetraloops/MyProject.git/'
muhammadkhalil@192 django_project %
Then
You can use token-based authentication in place of a password when performing Git operations. Github currently supports two types of personal access tokens: fine-grained personal access tokens and personal access tokens (classic). They recommend using fine-grained tokens whenever possible.
In the first step, we will create a personal Access Token on GitHub. Follow these steps to create one for your GitHub account:
Now, a new page is opened in which you can see your personal access token and copy it.
Now, we need to run the following command to use this access token:
INPUT
Configure Access Token on GitHub
In the first step, we will create a personal Access Token on GitHub. Follow these steps to create one for your GitHub account:
- Click on your GitHub profile icon on the top right corner and click on Settings
- Choose Developer Settings on the menu on the left
- Click fine-grained access tokens and Generate new token Add a specific note that will help you identify the scope of the access token
- Choose the Expiration period from the drop down menu and select the scopes you want to grant the corresponding access to the generated access token. Make sure to select the minimum required scopes. For this workshop, public_repo should be enough.
- Click on Generate Token
Now, a new page is opened in which you can see your personal access token and copy it.
Now, we need to run the following command to use this access token:
INPUT
$ git remote set-url origin https://<github-token>@github.com/<username>/<repository-name>.git
$ git push origin main
I had issues like this and there is no one specific set of instructions to resolve this. However I tried running this command and it worked for me
git config --global --unset http.proxy
Then run
git remote set-url origin <repository link>
After committing your new changes, try running this command if regular push gives you an error:
git push origin <branch> --force
fatal: the remote end hung up unexpectedlyHere is the answer
Here we go, I got my answer after trying too many ways in three days, for whoever will face this issue, do this stuff (read all below before starting):
- At first, Open Git Bash
- then, follow this instructions to generate SSH code and attach it to Github account.
- Go to Github repository page
- Click on Code button
- Change it to SSH
- Copy SSH CODE and use below, I determine your SSH code is git@github.com:user/user-repo.git
- In your terminal write git remote add origin-ssh git@github.com:user/user-repo.git, SSH CODE is which you copied one step before
- And finally push by git push -u origin-ssh
No comments:
Post a Comment