This repository is designed to walk you through some of the more common Git operations you will need to know and use as a developer.
Clone this repository to your local machine. You may need to install Git if it isn't already installed.
If you aren't sure if you have Git or not, simply run git --help from the command line.
It will return a helpful message with some common commands if it is installed.
git config --global user.name "your name"git config --global user.email "[email protected]"If you have questions or get stuck the following resources may help you.
Topics: Checkout, commit, revert, merge, log, move, and remove.
Files for the section can be found in the section1 directory.
dev branch.people.md.git commit --amend command.git status to see what files were changed.git add, but do not commit.git reset.git status should report no modified files.Tony made 3 commits to the dev branch. He misunderstood the project requirements and the changes introduced with his two last commits need to be removed.
git revert command which will keep the commits in the repository history, but remove the changes introduced by the commit.
Sometimes you may want to undo a commit you have made or even erase it from existence.
WARNING: This is generally considered bad practice. Only do this for commits you have not pushed to a remote repository (more on those later).
git reset HEAD~1git status.git reset --hard HEAD~1Someone checked in a temp file generated by their text editor. Stop git from tracking this file, remove it, and update the .gitignore file to prevent .tmp files from being tracked in the future.
Someone misnamed the rename_me.md file. Git has a command to move or rename a file while retaining its history. Use this to rename the file to newname.md.
Topics: Stash, diff, merge, merge conflicts
Files for this section can be found in the section2 directory.
Sometimes two people will make changes to the same file on separate branches. When these branches are merged it can cause a merge conflict. As the developer performing the merge it is your job to decide what changes to keep.
You have been tasked with updating the installation instructions for your product.
installation.md file and add install instructions (It doesn't matter what they actually say).Git has a function to stash local changes without committing them.
You are working on your local branch, when your coworker Taylor comes over and asks you to try running their code. You are not yet ready to commit your code, but you want to look at Taylor's branch without losing your progress.
stash_me.md file.git stash command to stash your work.git stash pop to get your work back.Topics: Remote repositories, syncing changes, and forking a repository.
At the beginning you cloned this repository from GitHub. You have all of your changes stored locally, now you need to share them. Git uses the concept of remotes to track where you cloned a repository from. you may also hear these referred to as the upstream repository. Right now the remote for your repository is set to the repository you cloned from.
To send you changes to a remote repository so others can view and use them you need to push them using the git push command.
You can see if any changes have been made to the remote repository by running git fetch.
To pull changes for the current branch into your local copy of the repository use the git pull command.
It is good practice to check for changes before pushing to a remote.
If you try to run git push right now you will get a message that you do not have permission to push to this repository. Most remote repositories have security in place to prevent just anyone from pushing their changes. You will make another remote copy of the repository that you can push your changes to.
Visit the repository on GitHub and fork it so you have a copy under your user account.
Now update the remote for the copy of the repository you changed, and push your changes to the dev branch to your fork on GitHub.
If a branch does not exist in the remote repository git will inform you.
Try pushing your branch. What is the message?
What do you need to do to push your new branch?