The first and most important thing if you’re a committer working on a branch shared with other committers is to never use the default git pull. Use the rebase version, git pull --rebase. That takes your commits that are not on the remote version of your branch and reworks/rebases them so that they’re ahead of (on top of) the new commits you pull in with your pull.

Assuming you are on the master branch checkout at a point of time.  You have progressed making changes adding and committing them to your local store.

user@sys204:~/projects/dc-server$ git status
On branch master
Your branch and ‘origin/master’ have diverged,
and have 1 and 1 different commit each, respectively.
(use “git pull” to merge the remote branch into yours)


Stage your local changes: Changes not staged for commit:
(use “git add <file>…” to update what will be committed)
(use “git checkout — <file>…” to discard changes in working directory)

modified:   app/controllers/api/
modified:   app/utils/
modified:   app/utils/
modified:   test/controllers/api/

Untracked files:
(use “git add <file>…” to include in what will be committed)


no changes added to commit (use “git add” and/or “git commit -a”)
user@sys204:~/projects/datacaptive-server$ git stash save “Package Factory in Place with Abstraction and Inheritance”

Saved working directory and index state On master: Package Factory in Place with Abstraction and Inheritance
HEAD is now at d8f3827 Bad Request Tests

user@sys204:~/projects/datacaptive-server$ git stash list
stash@{0}: On master: Package Factory in Place with Abstraction and Inheritance
stash@{1}: On master: Tests included for BadRequest, Exception Handling in fetchstatesforcountries
stash@{2}: WIP on master: 8829572 API Contracts, to return JSON responses. sabhi

user@sys204:~/projects/datacaptive-server$ git rebase
First, rewinding head to replay your work on top of it…
Applying: Bad Request Tests
Using index info to reconstruct a base tree…
M    app/controllers/api/
M    conf/application.conf
Falling back to patching base and 3-way merge…
Auto-merging conf/application.conf
Auto-merging app/controllers/api/
user@sys204:~/projects/datacaptive-server$ git stash apply stash@{0}
Auto-merging app/controllers/api/
CONFLICT (content): Merge conflict in app/controllers/api/

Posted in GIT