Wednesday, 10 May 2017

GIT, Diff and Resolve

Check for changes

git fetch --all
git status 

Compare
#current vs staged (local repository, previous to upload?) 
git diff 
#compare current against staged 
git diff <filename> 
 # in git > 1.6.1 cached replaced by staged 
git diff --staged 
#staged vs committed 
git diff --staged <filename> 

# browse changes 
git log 
git log -p #shows differences between commits 
git log -p -2 #limits output to 2 last commits

If you think that there will be conflicts, try to merge in dry-run mode
  
  git merge --no-commit --no-ff $BRANCH #Get the commits but do not apply yet
  git merge --abort #Discard last changes

If, anyway, conflict appears:

- Solve the conflict:  vi your/file.py
- git add your/file.py
- [git commit -m "Conflict solved"]

No comments:

Post a Comment