You can use the command line to move files within a repository by removing the file from the old location and then adding it in the new location.

Many files can be moved directly on GitHub Enterprise, but some files, such as images, require that you move them from the command line.

This procedure assumes you've already:

  1. On your computer, move the file to a new location within the directory that was created locally on your computer when you cloned the repository.
  2. Open TerminalTerminalGit Bash.

  3. Use 'git status' to check the old and new file locations.

    git status
    # On branch your-branch
    # Changes not staged for commit:
    #   (use "git add/rm ..." to update what will be committed)
    #   (use "git checkout -- ..." to discard changes in working directory)
    #
    #     deleted:    /old-folder/image.png
    #
    # Untracked files:
    #   (use "git add ..." to include in what will be committed)
    #
    #     /new-folder/image.png
    #
    # no changes added to commit (use "git add" and/or "git commit -a")
    
  4. Stage the files for committing to your repository. This will delete, or 'git rm', the file from the old location and add, or 'git add', the file to the new location.

    git add -A
    # Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.
    
  5. Commit the files that you've staged in your local repository.

    git commit -m "Move file to new directory"
    # 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 your GitHub Enterprise instance.

    git push origin master
    # Pushes the changes in your local repository up to the remote repository you specified as the origin
    

Further reading