GitHub was working perfectly fine when I started using it on my desktop exclusively but when I got onto my MacBook and started to use GitHub through XCode, that's when I noticed. When I change or add code to a project and commit it, my GitHub would not update until I commit it again. In other words its as if my GitHub is a commit behind. I'm extremely new to GitHub, so if any answers can be given in as little technical terms as possible I would really appreciate it. (Its my second day using GitHub). Thank you
Asked
Active
Viewed 214 times
0
-
Did you create a branch for your new commit? Did you clone your repository on multiple places, and first make a change to the first, then to the other clone? – Pieterjan Aug 20 '21 at 06:20
-
@Pieterjan I don't know what or how to use branches so no, and I didn't know how to download the GitHub files to my mac so yes I did clone it on my mac after cloning it on my desktop. – Rodolfo Aug 21 '21 at 00:47
-
Well if you do commits on the same branch from multiple places, you won't be able to push the branch to github rightaway. You have to pull the branch first, then perhaps resolve conflicts, and push the updated branch again. – Pieterjan Aug 21 '21 at 05:50
-
@Pieterjan So do I have to make a new branch on each device that I decide to clone my project to? I'm a little confused on how that works. Could you briefly explain how to do it correctly? Thank you – Rodolfo Aug 24 '21 at 05:32
-
In your case it's like this: When you open your computer and start working on the project, the first thing you do is `git pull` to fetch and merge all commits that were pushed to your branch while you were gone. But ideally there wouldn't be new commits since you should be the only person who pushes commits to your branch, unless as is the case with you, you have your branch checked out at multiple computers. Then you just issue a `git pull` from the moment you start working on the project. – Pieterjan Aug 24 '21 at 06:18
-
And if you are working in a team, then you'll most likely follow a [branching strategy as discussed in this thread](https://stackoverflow.com/questions/38048843/git-branching-model-strategy). Here you create a **branch per feature** you want to implement. All your code changes are pushed to this branch. From the moment you decide that your code changes are okay (1) you merge develop into your branch (2) optionally resolve conflicts (3) you merge your branch into develop either (a) by simply merging it yourself (b) by creating a pull-request which needs to be accepted by at least x other devs. – Pieterjan Aug 24 '21 at 06:27
-
@Pieterjan Thank you, I figured out what was wrong through this thread ->https://stackoverflow.com/questions/10169328/git-your-branch-is-ahead-of-origin-master-by-1-commit – Rodolfo Aug 25 '21 at 00:29