Some notes taken after going through a Git source control tutorial....
Description
Git Cheat Sheet 1.1 To initialize a Git repository in a local directory, enter the following command: git init 1.2 To see what the current state of the project is, type: git status 1.3 The "git status" command will show untracked files. 1.4 To start tracking changes to a file, the file must first be added to a s taging area by typing the following command: git add 1.5 Try "git status" to see the staged file. 1.6 The files are not in the repository yet because they are in the staging area. To store the staged changes, run the following command: git commit -m "" 1.7 Many files can be added using wildcards git add '*." 1.8 Continue to commit files in new commit entry. The files are added in a n ew commit entry compared to the first "git commit" command. 1.9 Git's log is a journal that remembers the changes committed so far. git log 2.0 Commits are to a local repository. To communicate with a network resposi tory, a url is required. 2.1 The remote repository must be added to allow the local repo to be pushed to the GitHub server. git remote add ex: git remote add origin git:github.com/splttingatms/try_git.git 2.2 Use the push command to push the commits to the repository. The push com mand requires the name of the remote git push (-u)? ex: git push -u origin master 2.3 Check for changes on repository by pulling down changes by running the f ollowing command: git pull ex: git pull origin master 2.4 Differences can be seen between the recent pull and the last commit. git diff ex: git diff HEAD 2.5 Look at changes within files that have already been staged. git diff --staged 2.6 Unstage files git reset ex: git reset octofamily/octodog.txt 2.7
Revert files to how they were at last commit with following command: git checkout -- ex: git checkout -- octocat.txt 1.18 To create a branch (local copy of code) to make separate commit, do the following command. The branch code can then be merged with main master branch. git branch ex: git branch clean_up 1.19 To switch branch run the following command. git checkout ex: git checkout clean_up 1.20 To remove files from local disk and stage the removal, run the following command. git rm ex: git rm '*.txt' 1.21 Commit the removal of files. Use commit command. ex: git commit -m "Remove all the cats" 1.22 To merge branches together, change back to branch. git checkout ex: git checkout master 1.23 To merge specified branch with current branch, run the command. git merge ex: git merge clean_up 1.24 To delete an unused branch, run the command. git branch -d ex: git branch -d clean_up 1.25 Final push of merged changes. Use previous push command. ex: git push
Thank you for interesting in our services. We are a non-profit group that run this website to share documents. We need your help to maintenance this website.