How to work with two devises and one repository #23754
-
Hello, I am novice with Github. So I am using it since a moment, but it first time, I upload my code to my own repository that I created. On a Rasberry I created a folder
I have created a pythion script with a class. First time I use it, I was helped with this
When I have done with a lot of code or when I wanted to upload new changes, I have used to do it with
and my changes was uploaded at github. My worries now, I have a new Raspberry and I would like to download the same script. To do it, it’s easy, but I am going to add new line of code and then pusing the change to the same repository, whith the command I know. Later, I would like to update the script on my first Raspberry, but what will happen in my repository if I push again from my first Raspberry? Do the repository will be overwritten by my old script from my first Pi? The idea is both Raspberry will download the lastest script version from the repository. Then from my second Raspberry, after downloading the repository, shoud I
and then after new changes
But then from my first, how can I update the change from the depository to the Raspberry? And if I add changes from the first Pi and I push, how to update the second without overwrite the latest version of the repository from a local version? I am starting to install my second Raspberry but I am afraid of a wrong git manipulation :slight_smile: Many thanks |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi pierrot10! It looks like you’ve got the hang of making changes to your code, committing it, and pushing the code up to the GitHub remote! The missing piece of the puzzle is Each time you start working with either one of the Raspberry Pis, you can run This help page has more details: https://help.github.com/en/github/using-git/getting-changes-from-a-remote-repository |
Beta Was this translation helpful? Give feedback.
-
Hello
That’s correct? But if I want to pull just on file, I supposed I can do as the following? sudo git pull https://github.com/user/repo/README.md |
Beta Was this translation helpful? Give feedback.
-
Hi there! The
You’ll then need to commit that file separately. As I mentioned though, it’s much more usual to just grab all changes, so |
Beta Was this translation helpful? Give feedback.
Hi there!
The
-u
flag is short for--upstream
- it tells Git “remember this relationship for future use”, so when you have used it once (usually on your first push) you don’t need to use it again.git pull origin master
is the most common workflow, and it will get all changes to the master branch and merge them in to your local copy. Mostly people prefer to get all changes from origin at the same time.git pull
is actually a combination of two commands,fetch
andmerge
, that you can run separately.git fetch origin master
will find out about all available changes to the master branch.git checkout FETCH_HEAD -- <specific file>
will grab only the specified file.You’ll then need to commit t…