Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,360,958
Community Members
 
Community Events
168
Community Groups

removing a file from the stage without changing it

I need to maintain a copy of a file in my local machine with different settings than the one stored in github. For example, localhost IP configs. My IP configs are only matching my own machine, it shouldn't be something that another person pulls. So, the copy in github needs to be 

<code>this is for everyone</code>

and mine needs to stay

<code> this is for me alone </code>

Problem is, when I change my file, sourcetree naturally recognizes the changes and adds it to the Unstaged Files portion for commit and push. I see some options when I right click but I'm not sure which one is the right one

right-click - remove (this deletes the file from my root I think)

right-click - Discard (this reverts my changes)

right-click - Stop Tracking (this creates a gitignore with the file path. It can't be ignored. it just needs to stay unchanged but able to be pulled)

 

Thoughts?

 

2 answers

1 accepted

0 votes
Answer accepted

I found from a different source that this can be done by opening your Git Terminal and typing the following command to tell SourceTree to assume the file has not changed

 

git update-index --assume-unchanged C:/$PATH/src/main/webapp/frontend/config/webpack/Base.js
Mike Corsaro Atlassian Team Feb 21, 2018

If you find yourself using the command frequently, you can also add a Custom Action to do this for you:

  • Open Tools > Options > Custom Actions
  • Add a new action
    • Menu caption: Assume Unchanged
    • Script to run: create a bat file with this as the content, and browse to that file:
      • git update-index --assume-unchanged %1
    • Parameters: $FILE
  • Hit OK

 

To use the custom action simply select the file in the modified file list, and then go to Actions > Custom Actions > Assume Unchanged

That is very helpful! Thank you!

I tried this but it gave me this error:

 

launch path not accessible

0 votes
Mike Corsaro Atlassian Team Feb 20, 2018

Hello! You can do this by creating a local non-shared ignore file. This will ignore changes to that file, but only for your local machine. To do that:

  • Navigate to your root ".git" folder in the repository
  • Create a file called "exclude" (no extensions) under the path "YOURREPO/.git/info"
  • Open the file, and add the ignore rule (for files, you can just write 'yourfolder/yourfile.blah' without the quotes, you don't need the full path, just the local one)

Thank you. However the file is still showing in the stage stack. 

basefile.png

My file structure looks like this

  • -root
  •   - .git (folder)
  •       - info (folder)
  •              exclude (file)
  •   - bin
  •   - optimizer
  •   - src
  •        - main
  •             - webapp
  •                   - frontend
  •                         - config
  •                                - webpack
  •                                       - Base.js
  • - .gitignore
  • - README.MD

 

My exclude file contains 

 

/src/main/webapp/frontend/config/webpack/Base.js

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Sourcetree

Bug Fix: Sourcetree for Windows authentication error when updating to app password

Hello Sourcetree users!!! With the recent removal of Bitbucket Cloud account passwords for app passwords (please see our Bitbucket Cloud community post for details on why we made this change for se...

79,067 views 134 29
Read article

Atlassian Community Events