User Tools

Site Tools


programming:git

Differences

This shows you the differences between two versions of the page.


programming:git [2021/04/11 10:29] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== GUI ======
 +[[https://gitea.io/en-us/]]
  
 +====== Init ======
 +<code>
 +    1. Sign on to SSH as root: ssh root@your_nas_ip
 +    2. Create the folder for your repository:  mkdir /opt/git/what_ever && cd /opt/git/what_ever
 +    3. Initialise the repository: git – bare init
 +    4. Exit SSH (exit)
 +    5. Navigate to the local git project folder: cd projects/etc
 +    6. git init + Add the remote repo: git remote add origin ssh://root@your_nas_ip/opt/git/what_ever
 +    7. Populate the remote repository: git push origin master (using your admin password)."
 +</code>
 +
 +====== Init repository and push it to origin ======
 +<code>
 +echo "# kingdom-msm8974" >> README.md
 +git init
 +git add README.md
 +git commit -m "first commit"
 +git remote add origin https://github.com/janforman/kingdom-msm8974.git
 +git push -u origin master
 +</code>
 +
 +====== Revert one Commit ======
 +<code>
 +git revert <commit hash>
 +</code>
 +
 +====== Revert to Commit ======
 +<code>
 +git checkout <commit hash>
 +</code>
 +
 +====== Show last changes ======
 +<code>
 +git show
 +</code>
 +
 +====== Discard local changes ======
 +<code>
 +git reset --hard
 +</code>
 +
 +<code>
 +git add .
 +git stash  
 +
 +git checkout <some branch>
 +</code>
 +
 +<code>
 + Cloning our fork
 +$ git clone git clone git@github.com:ifad/rest-client.git
 +
 +# Adding (as "endel") the repo from we want to cherry-pick
 +$ git remote add endel git://github.com/endel/rest-client.git
 +
 +# Fetch their branches
 +$ git fetch endel
 +
 +# List their commits
 +$ git log endel/master
 +
 +# Cherry-pick the commit we need
 +$ git cherry-pick 97fedac
 +
 +git push repository name
 +
 +git remote add other https://example.link/repository.git
 +git fetch other
 +</code>
 +
 +====== Show remote repositories ======
 +<code>
 +git remote -v
 +</code>
 +
 +====== Create patch ======
 +<code>git format-patch -1 HEAD</code>
 +
 +====== Apply patch ======
 +<code>
 +git apply yourcoworkers.patch
 +</code>
 +
 +
 +<code>
 +git clone url
 +</code>
 +
 +====== Change last revision ======
 +<code>
 +git commit -m 'initial commit'
 +git add forgotten_file
 +git commit --amend
 +</code>
 +
 +====== Merge ======
 +<code>
 +git fetch upstream
 +$ git checkout master
 +$ git merge upstream/master
 +$ git push
 +</code>
 +
 +====== Remove sensitive informations ======
 +<code>bfg --delete-files YOUR-FILE-WITH-SENSITIVE-DATA</code>
 +<code>bfg --replace-text passwords.txt</code>
 +
 +
 +====== Cherry Pick External Repo ======
 +<code>git fetch <remote-git-url> <branch> && git cherry-pick FETCH_HEAD
 +git fetch <remote-git-url> <branch> && git cherry-pick HASH</code>
 +
 +[[http://marklodato.github.io/visual-git-guide/index-en.html|GIT visual guide]]
programming/git.txt · Last modified: 2021/04/11 10:29 by Jan Forman