dkeg wrote:disclaimer, I'm sure Joe would have a more proper tutorial for this.
Generally speaking ... we're looking at two separate things here, using git locally and with a service such as GitHub or Bitbucket.
Using locally:initialize the directory, add the items, commitCode: Select all
sudo apt-get install git
First things first, create you ssh keyCode: Select all
cd /dir/for/git git init git add -A #above is all to add all items. You can add specific items too git add file1 file2 file3 git commit -m 'm is for message, add your message here' git status #check current status
Copy the public key and use that for your key in GitHub/BitbucketCode: Select all
ssh keygen -t rsa "email"
Connecting with a remote server. Pretty much the same as above, of course we need to specify our remote locationCode: Select all
cd ~/.ssh <editor> id_rsa.pub
When we push origin master, we push up to our remote GitHub account.Code: Select all
cd /dir/for/git git remote add origin [email protected]:gituser/reponame.git git push origin master
When you are happy with you current state, you can create a branch, and work off the branch.Move to the new branchCode: Select all
git branch <branchname>
Create and move to all in oneCode: Select all
git checkout <branchname>
Now you can do all your work on the branch, when you're happy, commit and merge it with masterCode: Select all
git checkout -b <branchname>
You can either keep the branch or deleteCode: Select all
git commit -m 'commit message' git checkout master # check the current working branch git branch git merge <branchname>
For cloning a repoCode: Select all
git branch -d <branchname>
To help keep my clones organized I create a git directoryCode: Select all
git clone [email protected]:gituser/reponame.git cd reponame # track it git remote add upstream git://github.com/gituser/reponame.git git fetch upstream # I generally do git pull
Code: Select all
mkdir git cd git git clone ..... be happy and organized
Other cool stuffMore disclaimer, please don't by shy about questions. Again, I am not a pro at this, its mainly from what I've picked up from personal use. There is obviously so much more that can be done, and possibly better ways to do stuff. For my configs and such I generally don't branch, but when I was coding, I would definitely branch.Code: Select all
git diff git log --graph
Hopefully I didn't leave anything important out.
Edit: IIRC when you add a remote origin,if its added as https, not ssh. You can change that with set-urlCode: Select all
git remote set-url origin [email protected]:gituser/reponame.git
HOWTO: Quick Git Guide
Forum rules
Share your brain ;)
Share your brain ;)
-
- Baconator
- Posts: 10253
- Joined: Thu Sep 16, 2010 11:03 am
- Location: Pfälzerwald
- Contact:
HOWTO: Quick Git Guide
This was originally a post by dkeg, I copy-paste it here to have GIT stuffin one place. Thanks Drew for the nice tutorial :)
..gnutella..
- wuxmedia
- Grasshopper
- Posts: 6454
- Joined: Wed Oct 17, 2012 11:32 am
- Location: Back in Blighty
- Contact:
Re: HOWTO: Quick Git Guide
nice, should use this more, I clone like crazy, but fail at updating via the command line.
Thanks Both!
Thanks Both!
Re: HOWTO: Quick Git Guide
Git lets you GPG sign your commits. Not a bad thing, so this is what's needed:
As long as you have your GPG key already set up, add this line to your ~/.gitconfig or ~/.config/git/config:
You can find out the key-id using:
It's the one after the "/" on the line that starts with "pub".
Now all that's left is:
The "-S" does the trick:
As long as you have your GPG key already set up, add this line to your ~/.gitconfig or ~/.config/git/config:
Code: Select all
signingKey = <your-public-key-id>
Code: Select all
gpg --list-public-keys
Now all that's left is:
Code: Select all
git commit -S -m <your commit message>
As a plus, GitHub confirms you did it right:-S[<keyid>], --gpg-sign[=<keyid>]
GPG-sign commit.
Re: HOWTO: Quick Git Guide
Thanks for yet another tasty guide, Bacon.
I've been looking for a quick n' dirty, no bullshit rundown like this for a while now.
I also enjoyed 'Git Happens' to wrap my brain around Git in general, including the lesser known features:
https://www.youtube.com/watch?v=Dv8I_kfrFWw
I've been looking for a quick n' dirty, no bullshit rundown like this for a while now.
I also enjoyed 'Git Happens' to wrap my brain around Git in general, including the lesser known features:
https://www.youtube.com/watch?v=Dv8I_kfrFWw
- wuxmedia
- Grasshopper
- Posts: 6454
- Joined: Wed Oct 17, 2012 11:32 am
- Location: Back in Blighty
- Contact:
Re: HOWTO: Quick Git Guide
relevant XKCD: http://xkcd.com/1597/
although, with this guide should be a sea change.
although, with this guide should be a sea change.
Re: HOWTO: Quick Git Guide
Just wanted to link to the official Git documentation as well (I enjoy using GitHub, but want to make others aware of other sources).GekkoP wrote:Git lets you GPG sign your commits. Not a bad thing, so this is what's needed:
Note that instead of editing the config, you can useGekkoP wrote: As long as you have your GPG key already set up, add this line to your ~/.gitconfig or ~/.config/git/config:You can find out the key-id using:Code: Select all
signingKey = <your-public-key-id>
It's the one after the "/" on the line that starts with "pub".Code: Select all
gpg --list-public-keys
Code: Select all
git config --global user.signingkey <your-public-key-id>
Re: HOWTO: Quick Git Guide
^ Thanks for the clarification.
That "git config" line is easier and quicker. Although I prefer editing the config by myself to see what's going on.
That "git config" line is easier and quicker. Although I prefer editing the config by myself to see what's going on.
Re: HOWTO: Quick Git Guide
I recently came across yet another post on git aliases (and actually decided to put them in my .gitconfig this time).
Here's what I snagged from the site, GitHowTo:
(Add to your .gitconfig)
Now I just need to remember to use them :)
Here's what I snagged from the site, GitHowTo:
(Add to your .gitconfig)
Code: Select all
[alias]
co = checkout
ci = commit
st = status
br = branch
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short