PHP Avenger
PHP Avenger

Reputation: 1801

Temporarily save git changes

I am having trouble with GIT repository, I want

  1. if I switch to another branch Production, changes in my current branch Development get saved some where(my be stashed)
  2. Switched branch Production remain intact of my previous changes.
  3. and when I switch back to previous Development branch I retrieve back my changes (stash pop).

I thought about stashing my changes but it is not working as per my expectations (or I might have understood it all wring).

if I had changes in 3 files before branch switch, I still can see 3 changes in checked-out branch. That is not what I am expecting.

Here are the steps I performed

D:\my-code>git status
On branch development
Your branch is up-to-date with 'origin/development'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        java/com/web1/cc/Category.java
        java/com/web1/cc/Product.java
        java/com/web1/cc/Relationship.java

nothing added to commit but untracked files present (use "git add" to track)

I though if I git-stash these files will be stashed but not happening.

D:\my-code>git stash
No local changes to save

Please note these 3 files are actually new files.

however if I again issue git status it show me 3 files changes.

I want to create build from Production branch and want to ignore these 3 files. (For now what I do is copy my src folder some where else and reset the changes, switch branch create build, switch back, merge changes that I save some where else).

I am hopeful I have explained my problem.

Upvotes: 0

Views: 170

Answers (1)

Rohit Shedage
Rohit Shedage

Reputation: 25910

The reason these files does not get stashed is that they are not under version control. You can try first adding them to version control by issuing command git add . and then git stash

Upvotes: 1

Related Questions