This is an open-source IT ebook introduction to Git and GitHub guide that will help you learn the basics of version control and start using Git for your SysOps, DevOps, and Dev projects. No matter if you are a DevOps/SysOps engineer, developer, or just a Linux enthusiast, you can use Git to track your code changes and collaborate with other members of your team or open source maintainers.The guide is suitable for anyone working as a developer, system administrator, or a DevOps engineer and wants to learn the basics of Git, GitHub and version control in general.Bobby Iliev has been working as a Linux DevOps Engineer since 2014 and is an avid Linux lover and supporter of the open-source movement philosophy.
Note that the connection would be in place if you used the git clone command to clone an existing repository from GitHub to your local machine. We will go through the git pull command in the next few 60 chapters as well. After running the git push command, you can head over to your GitHub project, and you will be able to see the commits that you've made locally, present on GitHub. If you were to click on the commits link, you would be able to see all commits just as if you were to run the git log command: Now that you know how to push your latest changes from your local Git project to your GitHub repository, it's time to learn how to pull the latest changes from GitHub to your local project. 61 Git Pull If you are working on a project with multiple people, the chances are that the codebase will change very often. So you would need to have a way to get the latest changes from the GitHub repository to your local
id: 12d7e9996a8d7cf11786b564fc8107b7 - page: 60
You already know that you can use the git push command to push your latest commits, so in order to do the opposite and pull the latest commits from GitHub to your local project, you need to use the git pull command. To test this, let's go ahead and make a change directly on GitHub directly. Once you are there, click on the README.md le and then click on the pencil icon to edit the le: Make a minor change to the le, add a descriptive commit message and click on the Commit Changes button: 62 With that, you've now made a commit directly on GitHub, so your local repository will be behind the remote GitHub repository. If you were to try and push a change now to that same branch, it would
id: 9873e038bab7cf1edae647c69c97547e - page: 62
[rejected] main -> main (fetch first) error: failed to push some refs to 'gitgithub.com:bobbyiliev/demo-repo.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. As stated in the output, the remote repository is ahead of your local one, so you need to run the git pull command to get the latest changes:
id: f5f1f7785f5b0c287cb378dc14e48eab - page: 63
remote: Counting objects: 100% (5/5), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), 646 bytes | 646.00 KiB/s, done. From github.com:bobbyiliev/demo-repo * branch main -> FETCH_HEAD da46ce3..442afa5 main -> origin/main README.md | 3 ++1 file changed, 2 insertions(+), 1 deletion(-) We can see that the README.md le was changed and that there were 2 new lines added and 1 line deleted. Now, if you were to run git log, you will see the commit that you've made on GitHub available locally. 64 Of course, this is a simplied scenario. In the real world, you would not make any changes directly to GitHub, but you would most likely work with other people on the same project, and you would have to pull their
id: d16fd4b3433b58627850455f8db7bcb6 - page: 64