Как загрузить файл на github windows

You can upload and commit an existing file to a repository on GitHub or by using the command line.

Adding a file to a repository on GitHub

Files that you add to a repository via a browser are limited to 25 MB per file. You can add larger files, up to 100 MB each, via the command line. For more information, see «Adding a file to a repository using the command line.» To add files larger than 100 MB, you must use Git Large File Storage. For more information, see «About large files on GitHub.»

Tips:

  • You can upload multiple files to GitHub at the same time.
  • If a repository has any protected branches, you can’t edit or upload files in the protected branch using GitHub. For more information, see «About protected branches.»

You can use GitHub Desktop to move your changes to a new branch and commit them. For more information, see «Committing and reviewing changes to your project.»

  1. On GitHub.com, navigate to the main page of the repository.
  2. Above the list of files, using the Add file drop-down, click Upload files.
    "Upload files" in the "Add file" dropdown
  3. Drag and drop the file or folder you’d like to upload to your repository onto the file tree.
    Drag and drop area
  4. At the bottom of the page, type a short, meaningful commit message that describes the change you made to the file. You can attribute the commit to more than one author in the commit message. For more information, see «Creating a commit with multiple co-authors.»
    Commit message for your change
  5. Below the commit message fields, decide whether to add your commit to the current branch or to a new branch. If your current branch is the default branch, you should choose to create a new branch for your commit and then create a pull request. For more information, see «Creating a new pull request.»
    Commit branch options
  6. Click Commit changes.
    Commit changes button

Adding a file to a repository using the command line

You can upload an existing file to a repository on GitHub.com using the command line.

This procedure assumes you’ve already:

  • Created a repository on GitHub, or have an existing repository owned by someone else you’d like to contribute to
  • Cloned the repository locally on your computer

Warning: Never git add, commit, or push sensitive information to a remote repository. Sensitive information can include, but is not limited to:

  • Passwords
  • SSH keys
  • AWS access keys
  • API keys
  • Credit card numbers
  • PIN numbers

For more information, see «Removing sensitive data from a repository.»

  1. On your computer, move the file you’d like to upload to GitHub into the local directory that was created when you cloned the repository.
  2. Open TerminalTerminalGit Bash.
  3. Change the current working directory to your local repository.
  4. Stage the file for commit to your local repository.
    $ git add .
    # Adds the file to your local repository and stages it for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.
  5. Commit the file that you’ve staged in your local repository.
    $ git commit -m "Add existing file"
    # Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
  6. Push the changes in your local repository to GitHub.com.
    $ git push origin YOUR_BRANCH
    # Pushes the changes in your local repository up to the remote repository you specified as the origin

Further reading

  • «Adding locally hosted code to GitHub»

Here I explain how I did it on Windows.

Make sure to install Git and GitHub.

After installation is complete, open Git Bash.

Enter image description here

So a window like below is going to pop up:

Enter image description here

Go ahead and type cd ~ to make sure you are in the home directory. You can check the address that you are in it by typing pwd;

Now you need to create a GitHub account. After creating a GitHub account, go ahead and sign in.

After you signed in, on the top right click on the + and choose “New Repository”

Enter image description here

Then in the opened window, type the name that you wish to have for the repository in the “Repository name” box. Add “Description (optional)” if you like, and mark “Initialize this repository with a README”. Then click on “Create repository”.

Enter image description here

Now go to your C drive; create a new folder and name it “git”. Now go to the “Git Bash” window; change the directory to c drive by typing cd ~; cd /c.
If you type ls there it would show you the folders there. Make sure it shows the Git folder there:

Enter image description here

Now go back to the browser; go to your GitHub page, click on the repository that you made, click on “Clone or download”, and copy the address that shows there (by choosing copy to clipboard).

Enter image description here

Now going back to “Git Bash”. Use the command cd git to go to the git folder; now write the following commands to connect to your GitHub (enter the username and password of your GitHub when it asks you):

git config --global user.name "Your Name"

And then: git config --global user.email youremail@domain.com.

Next type: git clone (URL), instead of the (URL), type the address of the GitHub repository that you copied from your GitHub page; (e.g., git clone https://github.com/isalirezag/Test.git).

Now if you do ls command you will see your repository there. If you also open the Git folder that you have in your window you will see that your repository is added as a folder.

Now use the cd command to go to the repository: cd Test

Go ahead and copy and paste any files that you want to put in this repository in that folder.

In order to transfer the files to your repository you need to do following now:

Type git

add filename (filename is the file name that you want to upload) or you can type the command below if you want to add all the files in the folder:

git add .

Then type: git commit -m "adding files". And then: git push -u origin master .

And then you should be all set. If you refresh your GitHub account, the files should be there :)

Here I explain how I did it on Windows.

Make sure to install Git and GitHub.

After installation is complete, open Git Bash.

Enter image description here

So a window like below is going to pop up:

Enter image description here

Go ahead and type cd ~ to make sure you are in the home directory. You can check the address that you are in it by typing pwd;

Now you need to create a GitHub account. After creating a GitHub account, go ahead and sign in.

After you signed in, on the top right click on the + and choose “New Repository”

Enter image description here

Then in the opened window, type the name that you wish to have for the repository in the “Repository name” box. Add “Description (optional)” if you like, and mark “Initialize this repository with a README”. Then click on “Create repository”.

Enter image description here

Now go to your C drive; create a new folder and name it “git”. Now go to the “Git Bash” window; change the directory to c drive by typing cd ~; cd /c.
If you type ls there it would show you the folders there. Make sure it shows the Git folder there:

Enter image description here

Now go back to the browser; go to your GitHub page, click on the repository that you made, click on “Clone or download”, and copy the address that shows there (by choosing copy to clipboard).

Enter image description here

Now going back to “Git Bash”. Use the command cd git to go to the git folder; now write the following commands to connect to your GitHub (enter the username and password of your GitHub when it asks you):

git config --global user.name "Your Name"

And then: git config --global user.email youremail@domain.com.

Next type: git clone (URL), instead of the (URL), type the address of the GitHub repository that you copied from your GitHub page; (e.g., git clone https://github.com/isalirezag/Test.git).

Now if you do ls command you will see your repository there. If you also open the Git folder that you have in your window you will see that your repository is added as a folder.

Now use the cd command to go to the repository: cd Test

Go ahead and copy and paste any files that you want to put in this repository in that folder.

In order to transfer the files to your repository you need to do following now:

Type git

add filename (filename is the file name that you want to upload) or you can type the command below if you want to add all the files in the folder:

git add .

Then type: git commit -m "adding files". And then: git push -u origin master .

And then you should be all set. If you refresh your GitHub account, the files should be there :)

Как добавить файл в репозиторий на Github?
С помощью обучающей статьи (https://guides.github.com/activities/hello-world/) получилось создать README.md,но о том,как добавить свой файл там ничего не сказано.

задан 8 янв 2016 в 11:34

david_I's user avatar

david_Idavid_I

1,0032 золотых знака15 серебряных знаков25 бронзовых знаков

1

Склонируйте удаленный репозиторий в вашу локальную папку, используя команду clone

git clone git://github.com/schacon/grit.git

Либо еще вариант

  1. Создайте ваш локальный репозиторий, вызовите в каталоге «проекта» команду git init
  2. Добавьте файлы в репозиторий командой git add <folder>(или <file>)(например, git add . — добавит рекурсивно все файлы в текущем каталоге в локальный репозиторий)
  3. Сделайте ваш первый локальный коммит в репозиторий git commit -m "First commit"
  4. Добавляем локальному репозиторию ссылку на удаленный репозиторий github git remote add origin https://github.com/user/repo.git
  5. Теперь можно сделать команду push в удаленный репозиторий git push origin master
    ,тем самым отправив вашу локальную ветку master на сервер origin(на github репозиторий). Теперь вы можете видеть добавленные файлы на github.

Если у вас имеется уже локальный репозиторий, и вы хотите его залить на github, то выполните все пункты, начиная с 4. После этого ваш локальный репозиторий будет располагаться на сервере github.

Дух сообщества's user avatar

ответ дан 8 янв 2016 в 12:05

Alexcei Shmakov's user avatar

7

Понравилась статья? Поделить с друзьями:
  • Как загрузить файл в ubuntu windows
  • Как загрузить windows с диска на ноутбук
  • Как загрузочный диск windows 7 перенести на флешку
  • Как загрузить установочный диск windows 7 на компьютер
  • Как загрузить windows после установки linux