Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chrisgervang/git-tips
https://github.com/chrisgervang/git-tips
Last synced: 10 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/chrisgervang/git-tips
- Owner: chrisgervang
- Created: 2013-06-13T08:56:28.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-07-10T21:33:18.000Z (over 11 years ago)
- Last Synced: 2024-04-15T07:01:06.423Z (7 months ago)
- Size: 105 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Create Local Branch #
First, you must create your branch locally. Create a branch for every feature you work on.
git checkout -b your_branch
# Basic Workflow #
git add -A .
git commit -m "message"
git status# Initial Push to Remote Github Repo #
After that, you can work locally in your branch, when you are ready to share the branch, push it. The next command push the branch to the remote repository origin and tracks it.
git push -u origin your_branch# Pull Remote Branch #
You and your teammates can pull remote branches like so:
git pull
git checkout origin/your_branch# Push Existing Branches After Initial Commit #
You can continue working in the branch and pushing whenever you want without passing arguments to git push (argumentless git push will push the master to remote master, your_branch local to remote your_branch, etc...)
git push
Teammates can push to your branch by doing commits and then push explicitly.
#Rebasing#
git rebase
// to be continued...To pull down the latest changes from the a branch to you local feature branch, you must merge the branch with your local feature branch.
git checkout your_branch
git merge branch_with_desired_code#Bad Practices: Don't merge master locally and push back up.#
This makes the commit history messy. Use pull requests instead.BAD: git checkout master
BAD: git merge your_branch
BAD: git pushBasically we don't want stuff committed to the master branch from a local repo. We want to use pull requests through git hub to commit production code.
#Merge In Via Pull Requests#
Push your branch up, then go to github and open a pull request between your code and the master branch. Then ask a backend guy to review the code and close the pull.
#Set Remote Url#
git remote set-url origin#Configuring Git#
First you need to tell git your name, so that it can properly label the commits you make.
git config --global user.name "Your Name Here"
Git saves your email address into the commits you make. The email address is used to associate your commits with your GitHub account.
git config --global user.email "[email protected]"
The last option we need to set will tell git that you don't want to type your username and password every time you talk to a remote server. This will set git to use the credential memory cache.
git config --global credential.helper cache
By default git will cache your password for 15 minutes. This can be change like so, with timeout setting in seconds.
git config --global credential.helper 'cache --timeout=3600'#restore a file killed by a pull#
git log --diff-filter=D
git checkout $commit~1 file/to/restore.jpg