100 lines
2.4 KiB
Markdown
100 lines
2.4 KiB
Markdown
Git
|
|
===
|
|
|
|
To create a repo
|
|
----------------
|
|
|
|
on gogs
|
|
|
|
1. git config --global user.name "<gogsusername>@whatever"
|
|
2. create repo in gogs
|
|
|
|
on computer
|
|
|
|
1. apt install git
|
|
2. git clone repo
|
|
3. touch README.md
|
|
4. git add -A
|
|
5. git commit -m "first commit"
|
|
6. git push origin master
|
|
|
|
To collaborate on an existing repo
|
|
----------------------------------
|
|
|
|
1. Be added as a collaborator
|
|
2. git clone <repo address (from gogs)>
|
|
3. `git checkout -b <branchname>`
|
|
- `-b` creates a new branch if one doesn't exist
|
|
- you can name branch anything, start w/ your gogs name
|
|
|
|
4. make changes
|
|
|
|
To push up your changes
|
|
-----------------------
|
|
|
|
1. `git checkout master`
|
|
2. `git pull origin master`
|
|
3. `git checkout <branchname>`
|
|
4. `git merge master`
|
|
5. `git add -A`
|
|
6. \~git commit -m "concise explanation of what I did"\~
|
|
7. `git push origin <yourname>`
|
|
8. submit a pull request
|
|
|
|
Change last commit before pushing: git add \[more files\] git commit
|
|
--amend
|
|
|
|
Walkthrough
|
|
===========
|
|
|
|
This little walkthrough uses this repository as an example.
|
|
|
|
Cloning
|
|
-------
|
|
|
|
`git clone https://irc.anarchyplanet.org/git/AnarchyPlanet/dox`
|
|
|
|
If you added a ssh key already: `git clone git@HOST:user/repo`
|
|
|
|
Forking
|
|
-------
|
|
|
|
To change a repository you'll need a local copy of it, this is called
|
|
forking a git repository.
|
|
|
|
You can do so by clicking on 'Fork' at the top right of the web
|
|
interface.
|
|
|
|
Remotes
|
|
-------
|
|
|
|
Git can manage multiple remote locations called `remotes`.
|
|
|
|
The default remote after cloning is `origin`. This makes sense when
|
|
cloning your own, if you started with someone else's repository it makes
|
|
sense to rename it to `upstream`:
|
|
|
|
`git remote rename origin upstream`
|
|
|
|
Now add your fork URL:
|
|
|
|
`git remote add origin git@irc.anarchyplanet.org:2222:USER/dox`
|
|
|
|
For this to work you need to define the key file in `.ssh/config`:
|
|
|
|
\`\`\` Host AP Hostname irc.anarchyplanet.org User git Port 2222
|
|
IdentityFile \~/.ssh/id~rsa~ \`\`\`
|
|
|
|
After this your .git/config should have these sections: \`\`\` \[remote
|
|
"upstream"\] url = <https://irc.anarchyplanet.org/git/AnarchyPlanet/dox>
|
|
fetch = +refs/heads/\*:refs/remotes/upstream/\*
|
|
|
|
\[remote "origin"\] url = AP:USER/dox fetch =
|
|
+refs/heads/\*:refs/remotes/origin/\* \[branch "master"\] remote =
|
|
upstream merge = refs/heads/master \`\`\`
|
|
|
|
Now you should be able to push:
|
|
`git push origin branchname --set-upstream origin branchname`
|
|
|
|
Edit this guide: <https://irc.anarchyplanet.org/pad/p/dox-git>
|