Skip to content

How to update local from remote repository (git pull –rebase)

For collaborative works for group page(like this site), check whenever whether you are on top of works including commits in remote.

Before you push your work(commit) to fabcloud.org, Add your work to local master branch

1
2
3
4
5
6
$ git status
$ git add . 
$ git commit -m "commit message" 

# Check if origin/master is in advance. It might be good to use GUI tool
$ git pull --rebase

If there is marge conflict, then git tells you. In that case, open VSCode and marge the source code manually.

marge conflict

You can select “current change”, “incoming change”, “both”… or you can change source code.

After resolve marge conflict,

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Check local master log
$ git status
$ git log --oneline --decorate

# If necessary, 
$ git add . 
$ git commit -m "commit message" 

# In this status, you might be "detached HEAD" status and you cannot push. 
$ git push
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use

    git push origin HEAD:<name-of-remote-branch>

$ git branch -a
* (no branch, rebasing master)
master
remotes/origin/HEAD -> origin/master
remotes/origin/master

# If you commit successfully like above, you can continue rebase by:
$ git rebase --continue
Successfully rebased and updated refs/heads/master.

# Then do proceed when your work is on the HEAD of your working tree:
$ git push

Last update: January 29, 2021