The Code to Blogging 0.4

jazzbozner profile image jazzbozner ・3 min read

When it comes to myself and maybe some of you new developers out there, project management can be a force to deal with. For starters, we’re going to have to get into the practice of using git commands in order to collaborate on a project. There are a wide range of commands, but for now we’ll try to keep it as basic as possible.

First, the developer is going to create the new project and source that project on a repo attached to their github account. This repo is the origin/production of the project or better yet the project manager's baby. That repo then will be copied for other github users where they will have a copy to work with.

Second, those working on the project will be connecting their pipelines (remotes) in order to develop the program (baby). From then on the project will have features added by those working on the project; project managers of the repo will then have the ability to approve the features that are passed to the repo.

Before any changes are to be done, we should really think about how we can track all of our changes without altering the master immediately or creating conflicting code with others that are working on the project. There lies branching. We will need to create separate branches that focus on what we are trying to alter. Once the changes are made to the local copy, the changes are going to be added, committed, and checked against the main repo for any conflicts (pull remote upstream). If the changes work like expected, then we can create a pull request for our manager to update the origin code.

Attached is a helpful cheat sheet:

Getting & Creating Projects

git init - Initialize a local Git repository

git clone github.com/[username]/[repository-name].git -
Create a local copy of a remote repository

Basic Snapshotting

git status - Check status

git add [file-name.txt] - Add a file to the staging area

git commit -m "message" - Commit changes

Branching & Merging

git branch - list branches (asterisk denotes current branch)

git branch -a -Lists all branches

git branch [branch name] - Create a new branch

git branch -d [branch name] - Delete a branch

git checkout -b [branch name] - Create new branch and switch to it

git branch -m [old branch name] [new branch name] - rename local branch

git checkout [branch name] - switch to a branch

git checkout -- [file-name.txt] - Discard changes to file

git merge [branch name] - Merge a branch into the active branch

git merge [source branch] [target branch] - merge branch into the targeted branch

git stash - stash changes in a dirty working directory

git stash clear - remove all stashed changes

Sharing & Updating Projects

git push origin [branch name] - Push a branch to your remote repo

git push -u origin [branch name] - Push changes to a remote repo

git push - Push changes to remote repository (remembered branch)

git push origin --delete [branch name] - Delete a remote branch

git pull - Update local repo to the newest commit

git pull origin [branch name] - Pull changes from a remote repo

git remote add origin ssh://git@github.com/[username]/[repository-name].git -
Creates remote repo

git remote set-url origin ssh://git@github.com/[username]/[repository-name].git -
Sets origin

Inspection & Comparison

git log - view changes

git log --summary - view changes(detailed)

git log --online - View changes (briefly)

git diff [source branch] [target branch] - Preview changes before merging

Ref: https://github.com/joshnh/Git-Commands

Posted on Mar 24 by:

jazzbozner profile



Hey Gang! Just wanted to let you know about a couple loves in my life; their names are: video games, food, tech, and cool stuff--you get the gist! :) Lul


markdown guide