IN4315 - Software Architecture

Git & GitHub

  1. I don’t have time to watch the How GitHub uses GitHub to build GitHub video. Summary please!
    Are you sure? The movie is awesome. Anyway, have a look at the following links:
  2. Help, I hardly have any experience with using the terminal!
    Well, knowing to use the terminal is very handy since a lot of tools can only be invoked through a terminal. Luckily for you, there are also graphical user interfaces available: SourceTree (Mac OS) and GitHub for Windows.
  3. How do I use git?
    As git is very popular, there are various resources available online. Just Google for ‘git tutorial’. A good ‘book’ is git book. It also contains a page with the basic commands of git. Furthermore you can use the cheat sheet provided by GitHub training, or you can do a git game, where you learn how to use git interactively.
  4. What is my work flow when using git?
    • Start from an issue if possible.
    • Branch from from master git branch MyAwesomeBranchName.
    • Go to the branch (‘checkout’ the branch) git checkout MyAwesomeBranchName; you can also create and checkout a branch in one step: git checkout -b MyAwesomeBranchName
    • Make your files and/or make your changes
    • When the changes are significant enough (new paragraph, working function etc.) add the files git add path/to/file and write your commit git commit -m "your message".
    • Push to the remote (origin) whenever you like git push origin MyAwesomeBranchName
  5. How to create a multiline commit message with git commit -m?
    Bash (the Unix shell you are probably working in) supports line breaks by simply pressing enter (NB: you shouldn’t have the closing quotes in place yet!). git commit -m "your commit title [enter] your commit body"
  6. Help, I wrote my commit message wrong!
    No worries, you can overwrite your last commit with the --amend flag: git commit --amend -m "your new message"
    You should be careful when using this after the commit has been pushed already, as others might have pulled it in already. If you want to repush the commit anyway, just push with the -f flag.
  7. What are some other git commands I should know?
    • git status shows in which branch you are and which files are added for your commit.
    • git reset HEAD resets the files you added.
    • git commit -p and git add -p will provide you an interactive mode of git. The interactive mode allows you to select the changes you want to commit. This is helpful when you made a bunch of changes that can be bundled in different commits.
    • git commit -am "your message" is a shortcut to add the files that are being tracked (new files are not tracked) and directly write your commit. Be careful! Check with git status which files you added before you write a commit message for changes you didn’t want to include.
  8. Help, I didn’t want these changes! How do I undo my last commit?
    Check this Stack Overflow question and the corresponding answer.
  9. I saw in git log my email. How can i use the github feature of the private email?
    Go to the settings page of Github and click on the checkbox Keep my email address private . After that Github will notify you that it is going to use an email like this: <someone>@users.noreply.github.com when performing web-based Git operations. You can use it also for all your commits running the following command in your terminal: git config --global user.email "<someone>@users.noreply.github.com "
  10. How to contribute to a project using a fork.
    1. Make sure the fork is up to date with the upstream project. Create a branch with a descriptive name like you normally would, make your changes and create a pull request to the upstream master branch.
    2. Team review approach: apply the same approach as above, but create a pull request to your fork’s master branch. Discuss the progress with your team and make changes until you are happy. Close the pull request (without merging) and create a new pull request to the upstream master branch. This way your private discussion will not become part of the upstream project history.
    3. Code review approach (advanced): Apply the same approach as above. You can place in line review comments attached to commits. Once all commmits have been made, create a new branch, cherry pick the relevant commits, and optionally squash the commits together. This final sequence of commits should explain your contribution to the upstream integrator. Create the pull request to upstream from this new branch.
  11. I would like to have my own private repository at GitHub, beside this organization. How can I do that?
    GitHub gives free accounts to students using their email from the institution they belong to. You can signup here.