Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-mini-2024-07-18· OpenAIAi2 WildChat-4.8M (AI2)

I have to accounts of github. One of them has a repository. But I want to add file…

  1. User

    I have to accounts of github. One of them has a repository. But I want to add file ("persistant.h") to this repository from the second account. It's like a team job. How can I make it?

  2. Assistant

    To add a file to a GitHub repository from a different account (like collaborating with a team member), you have a few options. Here’s a step-by-step guide on how you can add a file (persistent.h) to a repository owned by the first account while using your second account.

    Option 1: Collaborator Access

    1. Request Access: If you have a GitHub account with a different email address, you can ask the owner of the repository (your first account) to add your second account as a collaborator.

    2. Add Collaborator:

      • The owner should go to the repository on GitHub.
      • Go to Settings > Collaborators & teams.
      • Add your second GitHub account as a collaborator by typing in the username or email and clicking Add.
    3. Clone the Repository:

      • Open a terminal or Git Bash.
      • Clone the repository with the following command:
        git clone https://github.com/first-account/repository-name.git
        
      • Replace first-account with the owner account name and repository-name with the name of the repository.
    4. Switch to the Repository Directory:

      cd repository-name
      
    5. Add the File:

      • Use a text editor or command line to create persistent.h:
        touch persistent.h
        
    6. Stage and Commit:

      git add persistent.h
      git commit -m "Add persistent.h"
      
    7. Push Changes:

      git push origin main
      
      • Make sure to replace main with the appropriate branch name if it's different.

    Option 2: Fork the Repository

    If you cannot get collaborator access, you can fork the repository and create a pull request.

    1. Fork the Repository:

      • Log into your second GitHub account.
      • Navigate to the repository owned by the first account.
      • Click on the “Fork” button to create a copy of the repository in your second account.
    2. Clone Your Fork:

      git clone https://github.com/your-second-account/repository-name.git
      cd repository-name
      
    3. Add the File:

      • Create persistent.h using a text editor or command line:
        touch persistent.h
        
    4. Stage and Commit:

      git add persistent.h
      git commit -m "Add persistent.h"
      
    5. Push Changes:

      git push origin main
      
    6. Create a Pull Request:

      • Go to your forked repository on GitHub.
      • You’ll see a banner suggesting to create a pull request. Click on it.
      • Provide a title and description.
      • Submit the pull request.
    7. Merge Pull Request:

      • The owner of the original repository can then review and merge your pull request.

    Option 3: Direct Upload

    If you want to directly upload the file without cloning the repository:

    1. Log into Your First GitHub Account: Ensure you're logged into the second account that has collaborator access.

    2. Navigate to the Repository: Go to the repository where you want to add the file.

    3. Upload the File:

      • Click on Add file > Upload files.
      • Drag and drop persistent.h or use the file selector.
      • Scroll down and click Commit changes.

    By following any of these methods, you should be able to add the file to the GitHub repository from your second account.