I'm working on my branch named "hiep". On Gitlab, the "main" branch of my Teacher's repository has a new file. How can I get these new files to my branch?
Asked
Active
Viewed 818 times
-2
-
3Does this answer your question? [Update Git branches from master](https://stackoverflow.com/questions/3876977/update-git-branches-from-master). – TTT Jul 17 '21 at 15:13
-
Note, that linked question and answers specify `origin/master` but you can use the same answer for any remote branch name (e.g. `origin/main` etc.) Also, some of the answers explain that you can use `merge` or `rebase`, and some mention `merge` as the first option. My personal preference would strongly lean towards `rebase` over `merge`. – TTT Jul 17 '21 at 15:14
1 Answers
0
You can simply fetch the new commits using
git fetch origin main
where origin
refers to the remote branch from where you want to fetch the changes.

Anubhav Gupta
- 421
- 5
- 12
-
Git fetch only checks for changes in origin, to actually retrieve the file your teacher added you need to git pull – ffm_nosoup Jul 17 '21 at 10:34
-
@ffm_nosoup Umm, if so, then is this answer wrong? Would be really glad if you could point this out. https://stackoverflow.com/questions/292357/what-is-the-difference-between-git-pull-and-git-fetch – Anubhav Gupta Jul 18 '21 at 06:39