links:: Source Control for Test Automation with Git MOC
3.3 Cloning, Fetching, Merging and Pulling
3.3 Cloning, Fetching, Merging and Pulling
Fetching remote maser branch and merging with local working directory:
git fetch
git branch -vv
master f414bfa [origin/master: behind 1] first commit
git merge
Output:
$ git merge
Updating f414bfa..bfb46a1
Fast-forward
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[!Fast-forward]
a merge from a branch into another, one where the target branch, in our case that is the local master branch, has not diverged from the source branch.
Pulling is applied to master (current) branch only. Other branches are not touched.
We cannot pull any changes if there are any modified files in working directory.
- commit them to local repo OR
- stash them (save current changes and revert working directory to HEAD - latest commit)
git stash
git stash list
# output:
# stash@{0}: WIP on master: bfb46a1 Update 2 - remote edit
git stash pop
# this will remove stash from list of stashes and move stashed changes to working directory
$ git stash pop
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: README.md