Don't use Tower because somehow you'll manage to break everything in magical ways that make no sense to me.
Well I'm going to assume some things. If these things aren't true, assuming they are won't actually help on your part.
cd ~/workspace git clone firstname.lastname@example.org:[owner]/[project].git #You can copy the url from your project page on github, gitlab, bitbucket, etc. cd [project]
Never edit on master! Editing on master is like sleeping on train tracks: It might seem warm and comfortable but it will lead to your destruction! Before you start on any new feature or bug fix start a new branch. Short, but descriptive, names work best.
git checkout -b breaking_asset_pipeline
This will create a new branch and switch to it. If you want this branch on the remote repo you need to push it with the --upstream option. NOTE: If you don't need other computers to see this branch there's no reason to push it remote.
git push -u origin breaking_asset_pipeline
Note you can switch branches at any time with the checkout command:
git checkout [branch]
If you add or delete a file on purpose you'll want to add that to the repo like so:
git add path/to/file #for single file git add -A #for all files in the current directory
If you edit a file and it doesn't break everything you'll probably want to commit the changes:
Please note that this only commits the code to your local branch. If you want it on the remote branch be sure to push it there:
PRO TIP: If your unsure what files have been changed or just want to double check you can/should use the status command:
git status # On branch production # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: Gemfile # new file: Gemfile.lock
If you're satisfied with the content of your branch you'll probably want to merge it into a more permanent branch at some point. This is simply done by checking out the desired branch and merging your branch into it.
git checkout beta git merge breaking_asset_pipeline
When a feature has been finished and merged in you may want to delete it.
# To delete it from your local box. git branch -D breaking_asset_pipeline # To delete it from the remote repo. git push origin --delete breaking_asset_pipeline # OR git push origin :breaking_asset_pipeline
Try not to commit bad code, but if you do it's not the end of the world, unless of course you break the master branch of the 'planets/earth' repository. That would be very very bad! Probably even worse than breaking the internet.
git revert a6e02fceb # Will reverse commit number by creating a new commit. git revert HEAD # Will create commit to reverse most recent commit. git revert HEAD~3 # Will revert commit 3 commits ago.
If you want to delete all changes since a commit and remove it from history you can do that to.
git reset --hard a6e02fceb git push -f [origin master] # This will make it your most recent commit.
git rebase -i HEAD~3 # Will bring up the last 3 commits in an interactive vim shell.
I personally use these:
alias ga='git add -A' alias gs='git status' alias gm='git merge' alias gmm='git checkout master; git merge' alias gcm='git commit -a -m' alias gu='git pull' alias gp='git push' alias gcp='git cherry-pick' alias gc='git checkout' alias grh='git reset --hard' alias gcb='git checkout -b' alias gss='git stash save' alias gsa='git stash apply' alias gsl='git stash lists'