Manage Files from the Git Page

If you're a project member, you can browse, add, edit, rename, and delete a Git repository's files. You can also view commit histories for the files but you can't add or update files in a linked external Git repository.

You must be a project member to add or update a Git repository's files:

  1. In the left navigator, click Git Git.
  2. From the Repositories drop-down list, select the Git repository. From the Revisions Revisions drop-down list, select the branch.
  3. On the right side of the page, click Files, if necessary.
  4. Browse and click a directory name to open it.

    To go back to a file's or a sub-directory's parent directory, click / and select the file or directory from the menu. To go to the root directory, click Root icon. To copy a file's or a directory's path, click Copy to clipboard the Copy icon.

You can perform these file management tasks from the Git page:

Action How To

Add a file

  1. Click + File.
  2. In File Name, enter the file's name and extension.
  3. In the code editor, add or enter the file contents.
  4. Click Commit.
  5. In the Commit Changes dialog, enter a commit summary in the first text box, any details in the Details text box, and then click Commit.

To save the file to a new directory or a directory structure, include the file path in File Name. The path can be a relative path or an absolute path. To specify an absolute path, add a / in the beginning.

For example:

  • Enter test/text_file.txt to save the text_file.txt file in the test directory on the current path. If the test directory doesn’t exist, it’s created.
  • Enter /test/text_file.txt to save the text_file.txt file in the test directory on the root. If the test directory doesn’t exist, it’s created.

View a file's contents

In the Git page, browse to and click the file name link to see its contents. The file opens in File tab:
  • If you open a text file, its contents are displayed in a read-only editor.
  • File and Blame views clearly indicate that a file is a symlink or a submodule (a gitlink) and display information about the link's target.
  • The contents of empty files, large files, and binaries aren’t displayed but you can use the browser URL to download it.
  • If the file is a text file or an image (such as .png, .jpg, .bmp, and .gif), it’s displayed in the browser.

If the text content exceeds the width of the editor, use the arrow keys to scroll left, right, up, and down. You can also use the scroll buttons to scroll horizontally. Move the cursor to the editor's left or right edge and click Right Scroll Right Scroll icon or Left Scroll Left Scroll icon to scroll a character at a time.

To view the file in raw (unformatted) format in the web browser, click Edit the Edit icon, and select Raw. The contents of the opened file are displayed in a new tab or a window in the web browser.

View a file's details

The headers in the Files and Blame pages display the file size and number of lines of code (LOC) for each file. The tree view to the left indicates the file mode (whether a file is an executable, a symlink, a submodule, or a regular file) but only displays the file size for regular files.

Icons show the file mode in the Files and Blame page's headers as well in the tree listing, so you can quickly see that a file is an executable, a symlink, or a submodule.

Empty files, large files, and binaries are shown in a similar manner, where you see information about them, but not the contents of the files themselves.

View a file's annotations and commits

Open the file and click Blame.

The Blame view displays the open file's annotations for each updated code line (or group of code lines) along with commit information. The annotation includes commits that affected code lines, the author, the commit's date-time stamp, and the commit message.

Show annotated tag messages The Git page's Refs tab displays annotated tag messages.
Show a file's mode The diff view in the Git page's Compare tab displays the file mode.

Icons indicate the file mode in the File and Blame page's headers as well in the tree listing to the left so you can quickly see that a file is a regular file or an executable, a symlink, or a submodule (a gitlink) and, if it is a link, display information about the link's target.

Empty files, large files, and binaries are shown in a similar manner, where you see information about them, but not necessarily the contents of the files themselves.

Change a file's mode If you change a file's mode, in the Compare tab, the comparison screen shows details about any mode changes or displays a "No diff" message if the mode wasn't changed. If you do change the mode, say from regular to executable, you're notified of the change with a message that says, Mode change: Regular file->Executable file.

Edit, rename, or move a file

Open the file and click Edit the Edit icon. Edit the file’s contents in the code editor. To rename the file or move it to another directory, in the file name text box, enter the new name or path. Click Commit to save.

With the Git diff editor active, if you make a change in the file shown in the diff view, the view refreshes immediately. If you have another Files tab open (the editor in the Compare tab with the change isn't active), the diff info gets refreshed when you return to the tab it's in. The refresh happens as soon as you select the Compare tab.

Delete a file

To delete a file, click Actions Actions icon next to Edit the Edit icon, and select Delete. In the Commit Changes dialog box, enter the commit summary in the first text box, the details in the Details text box, and then click Commit.

When a file is deleted (or moved), any open diff editors associated with that file are closed.