Updating a Github Repository

godreborn

Welcome to the Machine
OP
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
do I just need to do a "git pull" to update the repository on my computer without having to delete, then re git clone a repository?
 

godreborn

Welcome to the Machine
OP
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
  • Like
Reactions: Kazesama

Sypherone

Gaming Ninja
Member
GBAtemp Patron
Joined
Apr 28, 2019
Messages
1,655
Trophies
2
Age
44
XP
2,819
Country
Germany
  • Like
Reactions: godreborn

godreborn

Welcome to the Machine
OP
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
let's say that the 3ds version of sm64 is updated on github, and I already have an earlier version of the source code on my computer, instead of deleting it and starting over, I could do something like git pull origin 3ds or main or whatever the branch is called, and it will update the necessary source code?
 

cherryduck

Well-Known Member
Member
Joined
Jul 1, 2007
Messages
331
Trophies
1
Age
34
Location
The far side of the moon
Website
Visit site
XP
1,617
Country
git checkout in the terminal and that's it? no adding in a branch or anything?

You use git checkout to switch branches, which requires you to specify the branch.

git pull updates the branch you have checked out.

Say I'm on the main branch and I want to switch to the 3ds branch:

git checkout 3ds
git pull

That's it, I'm now on the 3ds branch and it's up to date.
 
  • Like
Reactions: godreborn

godreborn

Welcome to the Machine
OP
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
You use git checkout to switch branches, which requires you to specify the branch.

git pull updates the branch you have checked out.

Say I'm on the main branch and I want to switch to the 3ds branch:

git checkout 3ds
git pull

That's it, I'm now on the 3ds branch and it's up to date.
thank you, my friend. that makes sense now.
 
  • Like
Reactions: cherryduck

godreborn

Welcome to the Machine
OP
Member
Joined
Oct 10, 2009
Messages
38,471
Trophies
3
XP
29,138
Country
United States
I'm still confused about the difference between git pull and git fetch. what if I want to download a specific commit?
 

cherryduck

Well-Known Member
Member
Joined
Jul 1, 2007
Messages
331
Trophies
1
Age
34
Location
The far side of the moon
Website
Visit site
XP
1,617
Country
Fetch checks if there are any updates, pull actually pulls those updates. To pull a specific commit you use git checkout *commit hash*.

It's not recommended though because then you end up in a detached state, and generally speaking you want the latest code. I guess it doesn't matter quite so much if you're not making changes and pushing them to the source repo but it is messy and will put your local copy in a weird state.
 
  • Like
Reactions: godreborn

thominho

Active Member
Newcomer
Joined
Feb 9, 2014
Messages
41
Trophies
1
Age
29
XP
1,131
Country
Greece
The "normal" way is to fetch all changes using "git fetch --all" and then update only the branches that you want to update to prevent conflicts with other branches of yours. Conflicts usually happen when you change a file that someone has made changes.

But the novice commands are:
git clone -> Download Repo to your Computer
git log -> to search older commits and their unique number
git checkout [BRANCH_NAME] -> Change Repo to the specified branch or change to a commit using the unique number
git pull -> Update Repo to your Computer to the latest changes
git add -> add changes
git commit -> persist locally changes with a message
git push -> send the persisted changes locally to online to allow others to see these changes
 
  • Like
Reactions: godreborn

9x0

Member
Newcomer
Joined
Jul 18, 2021
Messages
12
Trophies
0
XP
108
Country
Switzerland
The "normal" way is to fetch all changes using "git fetch --all" and then update only the branches that you want to update to prevent conflicts with other branches of yours. Conflicts usually happen when you change a file that someone has made changes.

But the novice commands are:
git clone -> Download Repo to your Computer
git log -> to search older commits and their unique number
git checkout [BRANCH_NAME] -> Change Repo to the specified branch or change to a commit using the unique number
git pull -> Update Repo to your Computer to the latest changes
git add -> add changes
git commit -> persist locally changes with a message
git push -> send the persisted changes locally to online to allow others to see these changes
Adding to novice commands, git status -> lists "staged" changes
Useful to check before git commit
Rework of novice commands are:
git clone -> Download Repo to your Computer
git log -> to search older commits and their unique number
git checkout [BRANCH_NAME] -> Change Repo to the specified branch or change to a commit using the unique number
git pull -> Update Repo to your Computer to the latest changes
git add -> add or "stages" changes
git status -> lists "staged" changes
git commit -> persist locally changes with a message
git push -> send the persisted changes locally to online to allow others to see these changes
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: https://youtu.be/d9wnSq_aP-0?si=T9bdloMD2dGzvnbf