This is a Git playground repository to practice in a real environment but without catastrophic consequences.
This is a playground, so you're free to play around with it: fork, clone, commit, push, pull, accept pull requests...
To fork this project, click the "Fork" button in the GitHub.com repository.
Type in your terminal:
$ git clone https://github.com/{username}/git-practice.git
Change directory:
$ cd git-practice
To create a branch
# Creates a new branch called "mybranch"
$ git branch mybranch
# Makes "mybranch" the active branch
$ git checkout mybranch
Open the file you want to modify with your favorite text editor (vim, emacs, Sublime...)
With vim, for example:
vim Contributors.md
Example: Add your name to the list and save the document.
If you do git status
you can see that the Contributors.md file has been modified but not committed yet.
$ git status
# On branch mybranch
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: Contributors.md
#
no changes added to commit (use "git add" and/or "git commit -a")
You can also do git diff
to see the difference between documents.
$ git diff
First you'll have to add the changes with:
$ git add Contributors.md
If you do git status
now, you'll see the following:
$ git status
# On branch mybranch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: README.md
And then commit the changes
$ git commit -m "Your message for the commit"
To push it back to your repository:
$ git push origin mybranch
To merge your changes into the pyladies-bcn git-practice. Check the info on github on Pull requests.
Or just go to your repo and you should see a green button saying Compare and pull request