Sandeep Nair
Sandeep Nair

Reputation: 3660

Having confusion to push code in GIT

Consider this folder structure in repository

Root
|----Plugins
|----|-----Plugin1
|----Themes
|-----|----Theme1

I have all the code pushed into the server. I have some local changes in Plugin1 folder which I have not committed and I don't want to right now. I have some changes in Theme1 folder which I need to commit. I can commit it all right, but when I push it complains me to do a pull or stash my changes. Isnt there an easy option to push changes of just one folder than having to worry about all the local changes in different folders under same repository? In SVN I can just individual checkin any files without worrying about the others.

Upvotes: 0

Views: 51

Answers (2)

mdup
mdup

Reputation: 8529

Of course you can git stash your change, this is the easiest and the fastest.

However, you can also choose to commit your WIP to a new branch, on which you will do development work until it is pushable to the world (at which point you will want to rebase/merge it on your mainline branch, then push your mainline branch).

Summary :

  1. Via stash
    • git add + git commit your soon-to-be-pushed modifications
    • git stash
    • [push and whatever you need to do]
    • git stash pop
    • continue development work
  2. Via a new branch
    • let's say you're initially on branch dev
    • git add + git commit your soon-to-be-pushed modifications
    • git checkout -b notready
    • git add + git commit your WIP modifications
    • git checkout dev
    • [push and whatever you need to do]
    • git checkout notready
    • continue development work

Upvotes: 0

manojlds
manojlds

Reputation: 301337

git stash IS the easy option. After doing the commit, stash, pull, push and then pop the stash.

Upvotes: 4

Related Questions